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 / rashmi sharma
#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 ? | 85 Yes | 41 No |
Post New Answer View All Answers
What is the difference between the = symbol and == symbol?
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
Which is better pointer or array?
How can I implement a delay, or time a users response, with sub-second resolution?
Explain how can I convert a number to a string?
Is int a keyword in c?
What is the difference between test design and test case design?
what is uses of .net
In c programming language, how many parameters can be passed to a function ?
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
What is the use of header files?
What is a constant and types of constants in c?
Can we increase size of array in c?
What is a macro in c preprocessor?
what is a constant pointer in C