C Programming (ج البرمجة)
Pages
Home Page
Programming and IT Research Center
Basic Electronic for C.S.E
Saturday, July 20, 2013
Sum of Digits in
Sum of Digits in C Program
#include<stdio.h>
main()
{
int n,a=0;
printf("Please enter a number: ");
scanf("%d",&n);
while(n>0)
{
a=a+n%10;
n=n/10;
}
printf("Sum of digits is: %d",a);
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment