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 / pavan kumar
#include<stdio.h>
int main()
{
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,sum;
printf("Enter the five digit number:");
scanf("%d",&sum);
a=sum%10;
b=sum/10;
c=b%10;
d=b/10;
e=d%10;
f=d/10;
g=f%10;
h=f/10;
printf("sum of the digits:%d",a+c+e+g+h);
}
| Is This Answer Correct ? | 7 Yes | 4 No |
Post New Answer View All Answers
What is use of bit field?
Is c dynamically typed?
What are the types of functions in c?
Why c is faster than c++?
What is structure in c explain with example?
cavium networks written test pattern ..
How is pointer initialized in c?
Write the syntax and purpose of a switch statement in C.
Why #include is used in c language?
what will be maximum number of comparisons when number of elements are given?
What is main function in c?
What is the full form of getch?
What is a keyword?
Explain argument and its types.
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above