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
Do you know what are the properties of union in c?
Process by which one bit pattern in to another by bit wise operation is?
in linking some of os executables are linking name some of them
What is the newline escape sequence?
What is the description for syntax errors?
What is file in c preprocessor?
Is null always equal to 0(zero)?
Why main function is special give two reasons?
Explain what is meant by 'bit masking'?
write a program to print data of 5 five students with structures?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
Who developed c language?
What is a char in c?
how to write optimum code to divide a 50 digit number with a 25 digit number??
What is the difference between arrays and pointers?