Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Sum of digits in the given number in C++

//SUM OF DIGITS IN THE GIVEN NUMBER
#include<iostream.h>
#include<conio.h>
void main()
{
int n,sum=0,a;
clrscr();
cout<<"Enter the number:";
cin>>n;
while(n != 0)
{
a=n % 10;
sum=sum + a;
n=n/10;
}
cout<<"Sum of the digits of given number is:"<<sum;
getch();

}