To add individual digits of a given
number
#include<iostream.h>
#include<conio.h>
main()
{
int
n, sum=0;
cout<<”Enter
the number.\n”;
cin>>n;
while(n!=0)
{
sum+=n%10;
n/=10;
}
cout<<sum;
getch();
}
0 comments:
Post a Comment