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
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
What is use of integral promotions in c?
What is #define used for in c?
Why main is not a keyword in c?
What is the use of void pointer and null pointer in c language?
Explain what is page thrashing?
Can a pointer be static?
write a program in c language to print your bio-data on the screen by using functions.
Explain how are portions of a program disabled in demo versions?
What is a keyword?
How can I read data from data files with particular formats?
What is the difference between exit() and _exit() function in c?
Does c have circular shift operators?
if (i = 0)printf ("True"); elseprintf("False"); Under what conditions will the above print out the string "True" a) Never b) Always c) When the value of i is 0 d) all of the above
pierrot's divisor program using c or c++ code