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 / richa
main()
{
int num , sum=0 ;
printf(" enter 5 digit no. " );
scanf(" %d " , num);
while (num!=0)
{ sum+=num%10;
num=num/10;
}
printf("sum is = %d " , sum );
getch();
}
Is This Answer Correct ? | 24 Yes | 16 No |
Post New Answer View All Answers
what is a constant pointer in C
What is derived datatype in c?
Why is c faster?
What is the basic structure of c?
Explain how do you sort filenames in a directory?
What is a rvalue?
What is structure padding in c?
What is union and structure?
Is boolean a datatype in c?
Explain bit masking in c?
What is volatile variable how do you declare it?
Why we use int main and void main?
What is break statement?
What is #ifdef ? What is its application?
What are global variables and explain how do you declare them?