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
When can a far pointer be used?
What is volatile variable how do you declare it?
For what purpose null pointer used?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
What is typedf?
What is structure pointer in c?
What are the rules for the identifier?
Explain can the sizeof operator be used to tell the size of an array passed to a function?
Explain b+ tree?
What is page thrashing?
What is the meaning of && in c?
In C, What is the #line used for?
Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
What is time null in c?
How do you print an address?