Hey can any1 figure out wat is wrong in this program...after i compiled it and executed the program ....I inputed the value of n...but after that it does not show the output...Can any1 help me plz..!!
The program which I wrote is below::
#include<iostream.h>
int sumofdigits(int n)
{
int sum=0, x;
while(n>0)
{
x=n%10;
sum+=x;
}
return sum;
}
void main()
{
int n, sum;
cout<<"Enter any number"<<endl;
cin>>n;
sum=sumofdigits(n);
cout<<"Sum of digits ="<<sum;
cout<<endl;
}