#include<stdio.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();
}
No comments:
Post a Comment