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
write a c program for swapping two strings using pointer
Dont ansi function prototypes render lint obsolete?
What is a struct c#?
What is the difference between fread buffer() and fwrite buffer()?
What does a pointer variable always consist of?
What is output redirection?
what do you mean by inline function in C?
What are void pointers in c?
Add Two Numbers Without Using the Addition Operator
How can I make sure that my program is the only one accessing a file?
What are multidimensional arrays?
How many bytes are occupied by near, far and huge pointers (dos)?
What are actual arguments?
What are the different types of constants?
Write a program to print "hello world" without using a semicolon?