Wednesday 6 July 2011

C programme for addition of sum of digits


#include <stdio.h>
#include <conio.h>
void main()
{
int a,sum=0,n;
clrscr();
printf("enter a number");
scanf("%d",&n);
while(n>0)
{
a=n%10;
sum=sum+a;
n=n/10;
}
printf("%d",&sum);
getch();
}

No comments:

Post a Comment