C Programs
C programs with their output
Home
Programs
About
Contact
Tuesday, 27 December 2011
C program to find the sum of digits of a number
#include<stdio.h>
main()
{
int r,s;
long n;
printf("Enter any number\n");
scanf("%ld",&n);
s=0;
while(n>0)
{
r=n%10;
s=s+r;
n=n/10;
}
printf("The sum of digits is %d",s);
}
You Like It!? Then kindly share with your Friends.
Facebook
Twitter
Google+
StumbleUpon
Digg
Delicious
LinkedIn
Pinterest
Technorati
Comments
0 Comments
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)