write a program to sum of its digit with using control
structure or with out using loop. for ex: let the number is
25634 then answer will be=2+5+6+3+4=20
Answer Posted / alex r.
// without loop
// for digit in DEC
#include <stdio.h>
int sum(int digit)
{
if (digit%10 != digit)
return digit%10 + sum(digit/10);
return digit;
}
int main(void)
{
int digit = 25634;
printf("\nSum:%d", sum(digit));
return 0;
}
Is This Answer Correct ? | 15 Yes | 7 No |
Post New Answer View All Answers
Do you have any idea about the use of "auto" keyword?
Do you know the difference between exit() and _exit() function in c?
What is an auto keyword in c?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
What is a node in c?
How is a macro different from a function?
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
What is static memory allocation? Explain
What is the significance of an algorithm to C programming?
Tell me the use of bit field in c language?
Explain what is page thrashing?
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
What is the scope of static variables in c language?
What is adt in c programming?
How do you do dynamic memory allocation in C applications?