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


Please Help Members By Posting Answers For Below Questions

When should we use pointers in a c program?

600


If the size of int data type is two bytes, what is the range of signed int data type?

563


What is the advantage of an array over individual variables?

708


What are the different types of control structures in programming?

636


What is new line escape sequence?

784






How can I do graphics in c?

574


What is function prototype in c language?

587


What are the features of the c language?

623


Explain how do you use a pointer to a function?

614


Why is void main used?

594


What are qualifiers and modifiers c?

528


When should a type cast be used?

556


process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,

1862


Do character constants represent numerical values?

817


how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?

1483