Program for calculating Sum of Digits of a given Number
#include<stdio.h> #include<conio.h> main ( ) { int n, s,n,r ; 0; printf (“enter a number”); scanf (“%d”, &n); ...
https://www.computersprofessor.com/2016/06/program-for-calculating-sum-of-digits.html
#include<stdio.h>
#include<conio.h>
#include<conio.h>
main (
)
{
int n, s,n,r ; 0;
printf (“enter a number”);
scanf (“%d”, &n);
while (n! = 0)
{
r = n% 10;
s = r + s;
n = n/10;
printf (“sum of digits is % d”, r);
}
}
getch();
}
Out
Put:
Enter a number 567
Sum of digits is 18





























