Search This Blog

Sunday, 14 October 2012

Write a c++ program to find the sum of digits

#include<iostream.h>
#include<conio.h>
void main()
{
int n,s=0,d;
cout<<"Get Number";
cin>>n;
while(n>0)
{
d=n%10;
}
cout<<"Sum of digits of given number"<<n <<"is"<<s;
getch()
}

output:
Get Number
2345
Sum of digits of Given number 2345 is 14

No comments:

Post a Comment