Computer Science, asked by raja249, 1 year ago

Find the sum of digits of a number using c programming?

Answers

Answered by Ujjwal2018
0
1. Take the integer as input.
2. Divide the input integer by 10, obtain its remainder and quotient.
3. Increment the new variable with the remainder got at step 2.
4. Repeat the step 2 & 3 with the quotient obtained until the qoutient becomes zero.
5. Print the output and exit.

Hope this will help you!!!
Answered by Pravallika12
4
#include<stdio.h>
int main() {
int n;
int s = 0;
while (n > 0) {
int r = n % 10;
s = s + r * 10;
n = n / 10;
}
printf("sum of digits in number is%d",s);
return 0;
}
Similar questions