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 / jyoti
#include<stdio.h>
int main()
{
int n,d1,d2,d3,d4,d5,s;
printf("enter a five digit no");
scanf("%d",&n);
d5=n%10;n=n/10;
d4=n%10;n=n/10;
d3=n%10;n=n/10;
d2=n%10;n=n/10;
d1=n%10;
s=d1+d2+d3+d4+d5;
return 0;
}
| Is This Answer Correct ? | 29 Yes | 13 No |
Post New Answer View All Answers
Which is an example of a structural homology?
What is variables in c?
What is the symbol indicated the c-preprocessor?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.
write a program for the normal snake games find in most of the mobiles.
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions
Why cant I open a file by its explicit path?
When is a “switch” statement preferable over an “if” statement?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
what are the advantages of a macro over a function?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
Can we use visual studio for c?
Explain how do you override a defined macro?