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 / amit amar mahesh bhava
#include<sthio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f,g,h,i,j,k,l;
printf("enter a five digit number");
scanf("%d",&a);
b=a%10;
c=a/10;
d=c%10;
e=c/10;
f=e%10;
g=e/10;
h=g%10;
i=g/10;
j=i%10;
k=i/10;
l=b+d+f+h+j;
printf("sum of the digit=%d",l);
getch();
}
| Is This Answer Correct ? | 7 Yes | 5 No |
Post New Answer View All Answers
How do you search data in a data file using random access method?
Explain how do you sort filenames in a directory?
i have a written test for microland please give me test pattern
Explain how can I prevent another program from modifying part of a file that I am modifying?
Is c procedural or object oriented?
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above
Is main an identifier in c?
shorting algorithmS
Difference between Shallow copy and Deep copy?
int far *near * p; means
please explain every phase in the "SDLC" in the dotnet.
Explain main function in c?
What is NULL pointer?
How can my program discover the complete pathname to the executable from which it was invoked?
what are # pragma staments?