C Program To Print Sum Of n Digit Number

How to write a C Program To Print Sum Of n Digit Number in C Programming Language ?


Solution For C Program  :

/*C Program To Print Sum Of n Digit Number.*/

/*Program works good upto 9-digit.*/
#include<stdio.h>
#include<conio.h>
void main()
{
long int n,rem,sum=0;
clrscr();
printf("Enter the number==>");
scanf("%ld",&n);
while(n>0)
{
rem=n%10;
n=n/10;
sum=sum+rem;
}
printf("%ld",sum);
getch();
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable




Learn More :