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
When should we use pointers in a c program?
If the size of int data type is two bytes, what is the range of signed int data type?
What is the advantage of an array over individual variables?
What are the different types of control structures in programming?
What is new line escape sequence?
How can I do graphics in c?
What is function prototype in c language?
What are the features of the c language?
Explain how do you use a pointer to a function?
Why is void main used?
What are qualifiers and modifiers c?
When should a type cast be used?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
Do character constants represent numerical values?
how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?