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
What do you mean by recursion in c?
Explain how can I prevent another program from modifying part of a file that I am modifying?
Explain how does flowchart help in writing a program?
What is volatile variable in c with example?
Why c is called a middle level language?
Can we replace the struct function in tree syntax with a union?
In C, What is the #line used for?
What is the use of pointers in C?
What is main () in c?
how should functions be apportioned among source files?
If jack lies on Mon, Tue Wed and jill lies on Thursday, Friday and Saturday. If both together tell they lied yesterday. So c the given options and then c cos in the given dates one will be saying the truth and one will be lying. I got Thursday as option because jack is saying the truth he lied yest but jill is lying again as he lies on that day.
Are comments included during the compilation stage and placed in the EXE file as well?
how to build a exercise findig min number of e heap with list imlemented?
What are the back slash character constants or escape sequence charactersavailable in c?
What is #include stdio h and #include conio h?