Business Studies, asked by smen5513, 1 month ago

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 DDR108
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 Jasleen0599
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