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.'%')
Answer Posted / richa
main()
{
int num , sum=0 ;
printf(" enter 5 digit no. " );
scanf(" %d " , num);
while (num!=0)
{ sum+=num%10;
num=num/10;
}
printf("sum is = %d " , sum );
getch();
}
| Is This Answer Correct ? | 24 Yes | 16 No |
Post New Answer View All Answers
How can you check to see whether a symbol is defined?
Can you please explain the difference between exit() and _exit() function?
What is actual argument?
What is merge sort in c?
What is the heap in c?
What is the difference between āgā and āgā in C?
formula to convert 2500mmh2o into m3/hr
What is file in c preprocessor?
What is the difference between null pointer and wild pointer?
How many levels of indirection in pointers can you have in a single declaration?
How reliable are floating-point comparisons?
The difference between printf and fprintf is ?
What is difference between scanf and gets?
What are pointers really good for, anyway?
Can we declare a function inside a function in c?