Computer Science, asked by vanushree611, 9 months ago

WAP to input a number and print sum of its digit.​

Answers

Answered by nilavraghosh17
4

The program output is also shown below.

* C program to accept an integer & find the sum of its digits.

long num, temp, digit, sum = 0;

printf("Enter the number \n");

scanf("%ld", &num);

temp = num;

while (num > 0)

digit = num % 10;

sum = sum + digit;

Similar questions