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 advantage of pointer in c?
Are enumerations really portable?
Why is c called c not d or e?
Why we not create function inside function.
How to compare array with pointer in c?
Here is a good puzzle: how do you write a program which produces its own source code as output?
what is the format specifier for printing a pointer value?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
Does c have an equivalent to pascals with statement?
How does sizeof know array size?
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
What is the difference between typedef struct and struct?
What is the difference between c and python?
What is the use of a conditional inclusion statement in C?
How does free() know explain how much memory to release?