229k views
4 votes
Wap to find to sum the digits of a positive integer which is 5 digits long.​

1 Answer

2 votes

Answer:

Step-by-step explanation:

#include

int main()

{

int n, sum = 0;

printf("Enter a five digit number: ");

scanf("%d", &n);

while (n != 0) {

sum = sum + n % 10;

// removing last digit from number

n /= 10;

}

printf("Sum of digits: %d",sum);

return 0;

}

User Fanruten
by
3.4k points