THE 'C'- ARCHIE STYLE...
Thursday, March 31, 2011
Calculate Sum of digits of an integer
void main()
{
int n,a,c=0;
clrscr();
printf("enter the no.");
scanf("%d",&n);
while(n!=0)
{
a=n%10;
n=n/10;
c+=a;
}
printf("sum of digits=%d",c);
getch();
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment