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 / sriharsha
void main()
{
long int num;
int sum=0,temp;
clrscr();
printf("Enter the numbe\n");
scanf("%ld",&num);
while(num!=0)
{
temp=num%10;
sum=sum+temp;
num=num/10;
}
printf("%d",sum);
getch();
}
| Is This Answer Correct ? | 111 Yes | 42 No |
Post New Answer View All Answers
Is it possible to pass an entire structure to functions?
Explain how do I determine whether a character is numeric, alphabetic, and so on?
How can I write a function analogous to scanf?
Difference between pass by reference and pass by value?
What are global variables and explain how do you declare them?
Write a program on swapping (100, 50)
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?
Which type of language is c?
What is a built-in function in C?
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above
What is const and volatile in c?
What does the error message "DGROUP exceeds 64K" mean?
Why is event driven programming or procedural programming, better within specific scenario?
What is c basic?
I heard that you have to include stdio.h before calling printf. Why?