2:18 PM
C++ Program to show SUM OF THE DIGITS OF A NUMBER

Write a Program to show SUM OF THE DIGITS OF A NUMBER

 
#include<iostream.h> 
#include<conio.h> 
 
void main()
{
int num,sum=0,r;
clrscr();
printf("\nEnter a number:");
scanf("%d",&num);
while(num)
{
r=num%10;
num=num/10;
sum=sum+r;
}
printf("sum=%d",sum);
getch();
}
 
 
 
 
Note:    
           If you want to change in this program please write through the comment on this page. you can also paste similar program of 
             c++ with output.your comment is valuable to the other user and person.
Views: 100 | Added by: vijoriya | Tags: Digits, c++, Sum, Number, program | Rating: 0.0/0
Total comments: 0
avatar