C program to find sum of digits of the entered number.

 Program :

#include<stdio.h>
#include<conio.h>
void main()
{ int i,a,s=0;
clrscr();
printf("Enter any number\n");
scanf("%d",&a);
while(a)
{
i=a%10;
a=a/10;
s=s+i;
}
printf("The sum of digits is %d",s);
getch();
}

Output :



Comments