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
can any one tel me wt is the question pattern for NIC exam
What does sizeof function do?
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
How to compare array with pointer in c?
What is "Hungarian Notation"?
What is a macro, and explain how do you use it?
What is the best way to store flag values in a program?
explain what are actual arguments?
Differentiate between ordinary variable and pointer in c.
What is the difference between variable declaration and variable definition in c?
Explain Function Pointer?
What are the 4 types of unions?
How will you declare an array of three function pointers where each function receives two ints and returns a float?
What is bubble sort technique in c?
Explain the use of bit fieild.