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 / k.kavitha
main()
{
int num=0,sum=0,k=0;
pirntf("enter the number\n");
scanf("%d",num);
while(num!=0);
{
k=num%10;
sum=sum+k;
num=num/10;
}
printf("%d",sum);
}
| Is This Answer Correct ? | 137 Yes | 90 No |
Post New Answer View All Answers
How can I copy just a portion of a string?
how to find anagram without using string functions using only loops in c programming
What is typedef example?
What is the difference between constant pointer and constant variable?
What is the difference between near, far and huge pointers?
find out largest elemant of diagonalmatrix
Explain continue keyword in c
write a c program for swapping two strings using pointer
Explain what is the difference between functions getch() and getche()?
Where does the name "C" come from, anyway?
What are the similarities between c and c++?
How can I send mail from within a c program?
How can you be sure that a program follows the ANSI C standard?
What is the difference between malloc() and calloc()?
what is a NULL Pointer? Whether it is same as an uninitialized pointer?