(Move to ...)
▼
Program: Sum of digits of an integer
#include <iostream.h>
main()
{
int num , temp , sum = 0 ;
cout<<"Enter an integer value :\n";
cin>>num;
do
{
temp = num % 10 ;
sum = sum + temp ;
num = num / 10 ;
}
while (num != 0) ;
cout<<"The sum of individual digits is "<<sum;
}
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment