If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator '%')
Answers
Answered by
98
Answer:If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator '%') - Garbage Value.
THANKS=THANKS
FOL.LOW ME IF YOU WANT MORE THANKS
MARK THIS BRAINLIEST TO GET THANKS
Answered by
2
C Program
#include<stdio.h>
#include<conio.h>
int main()
{
int num,a,b,c,d,e;
printf("Enter a five digit number : ");
scanf("%d", &num);
e=num%10;
d=(num/10)%10;
c=(num/100)%10;
b=(num/1000)%10;
a=(num/10000);
printf("%d is the sum of the digits of the number %d.", a+b+c+d+e, num);
getch();
return 0;
}
- get the user's number
- Obtain the number's residual or modulus.
- Add up the remaining amount.
- Multiply the result by 10.
- While the number is more than 0, repeat step 2 once more.
#SPJ2
Similar questions
Math,
19 days ago
Social Sciences,
19 days ago
Math,
19 days ago
World Languages,
1 month ago
Science,
8 months ago
Social Sciences,
8 months ago