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
Differentiate between static and dynamic modeling.
Can we use any name in place of argv and argc as command line arguments?
Explain how can I convert a number to a string?
What is define c?
What are pointers? What are different types of pointers?
How do I get a null pointer in my programs?
What are the types of type qualifiers in c?
What is the advantage of c?
Tell us two differences between new () and malloc ()?
Write the control statements in C language
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
How to write a multi-statement macro?
What are the types of pointers?
Why we not create function inside function.
What is the heap?