Question: Redo the program below by reading each digit of the number to be tested into a type char variable digit . Display each digit and

Redo the program below by reading each digit of the number to be tested
into a type char variable digit . Display each digit and form the sum of the
numeric values of the digits. Hint: The numeric value of digit is (int) digit - (int) '0'.

#include <stdio.h>

int main()

{

int n = 154368;

  

int sum = 0;

  

while(n)

{

printf("%d ",n%10);

sum = sum+n%10;

n = n/10;

}

  

if(sum%9==0)

printf("\nTrue");

else

printf("\nFalse");

return 0;

}

Step by Step Solution

3.45 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve the problem of reading each digit of the number into a char variable we need to treat the n... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!