Find sum of digits of a given number.
This post content:-
Algorithm
Flowchart
C code
Output
Pdf notes
Algorithm:-
Step 1:- start.
Step 2:- declare variable num.
Step 3:- make a function to get a sum.
As follow:-
int getSum(int n)
{
int sum = 0;
while (n != 0) {
sum = sum + n % 10;
n = n / 10;
}
return sum;
}
Step 4:- end.
C code:-
Comments
Post a Comment