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 we can insert comments in a c program?
Define Array of pointers.
What are the application of c?
What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.
What is a stream water?
List the difference between a "copy constructor" and a "assignment operator"?
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions
FILE PROGRAMMING
What is the argument of a function in c?
Is c++ based on c?
how logic is used
Explain the advantages of using macro in c language?
Explain modulus operator. What are the restrictions of a modulus operator?
Is there any demerits of using pointer?
What does calloc stand for?