#include<stdio.h>
#include<conio.h>
main()
{
int n,sum=0,r;
clrscr();
printf("Enter the number\n");
scanf("%d",&n);
while(n>0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
printf("\nSum of digits is : %d",sum);
}
#include<conio.h>
main()
{
int n,sum=0,r;
clrscr();
printf("Enter the number\n");
scanf("%d",&n);
while(n>0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
printf("\nSum of digits is : %d",sum);
}
No comments:
Post a Comment