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
What is sizeof array in c?
How can I implement sets or arrays of bits?
When can you use a pointer with a function?
the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters
Explain how does free() know explain how much memory to release?
How can you restore a redirected standard stream?
What is the explanation for prototype function in c?
What is spark map function?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
Explain what are compound statements?
What is pragma c?
What is a function simple definition?
Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.
Disadvantages of C language.
What is use of pointer?