Computer Science, asked by mondalbidyut25, 5 months ago

write a program to input a number and display the sum of its digts using the white loop​

Answers

Answered by Anonymous
0

Answer:

C program to find sum of digits using for loop

int main() { int n, sum = 0, r;

printf("Enter a number\n");

for (scanf("%d", &n); n != 0; n = n/10) { r = n % 10; sum = sum + r; }

printf("Sum of digits of a number = %d\n", sum);

return 0; }

Similar questions