Monday, March 12, 2012

sum of digit of number


#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,rem,sum=0;
clrscr();
printf("enter the  no:>");
scanf("%d",&n);
for(;n>0;i++)
{
rem=n%10;
sum=sum+rem;
n=n/10;

}
printf ("the sum of digit of no is %d",sum);
getch();
}

No comments:

Post a Comment