#include <iostream>
#include<conio.h>
using namespace std;
main()
{
int num,i, digit, sum=0;
cout<<"Enter Number "; cin>>num;
i=num;
while(num!=0)
{
digit = num % 10;
sum = sum + digit ;
num/=10;
}
cout << "Sum of digits of number " <<i
<<" is "<<sum << endl;
getch();
}
#include<conio.h>
using namespace std;
main()
{
int num,i, digit, sum=0;
cout<<"Enter Number "; cin>>num;
i=num;
while(num!=0)
{
digit = num % 10;
sum = sum + digit ;
num/=10;
}
cout << "Sum of digits of number " <<i
<<" is "<<sum << endl;
getch();
}
No comments:
Post a Comment