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
To solve the problem of reading each digit of the number into a char variable we need to treat the n... View full answer
Get step-by-step solutions from verified subject matter experts
