Sum of Digit
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n,num,x,sum=0;
printf("Enter a number=");
scanf("%d",&n);
while(n>0)
{
x=n%10;
sum=sum+x;
n=n/10;
}
printf("Sum of digits of a number=%d",sum);
getch();
}
Dear User,
Thank you for your comment. Hope you like this blog. Kindly share us on Social Media so others can be updated.
-Chief Administrative Officer.
Note: only a member of this blog may post a comment.