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 / k.kavitha
main()
{
int num=0,sum=0,k=0;
pirntf("enter the number\n");
scanf("%d",num);
while(num!=0);
{
k=num%10;
sum=sum+k;
num=num/10;
}
printf("%d",sum);
}
| Is This Answer Correct ? | 137 Yes | 90 No |
Post New Answer View All Answers
What does %p mean?
pierrot's divisor program using c or c++ code
What is a char c?
Why do we use static in c?
Why does the call char scanf work?
Difference between linking and loading?
What is dynamic memory allocation?
cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration
What is const volatile variable in c?
Which built-in library function can be used to match a patter from the string?
what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above
Is a house a shell structure?
write a programming in c to find the sum of all elements in an array through function.
If you know then define #pragma?
Is fortran faster than c?