Program to find the sum of digits of a given number until
the sum becomes a single digit
Answer Posted / somasundaram
#include<stdio.h>
#include<conio.h>
void main()
{
unsigned int no;
clrscr();
printf("Enter number : ");
scanf("%d", &no);
if(no==0)
printf("sum = 0");
else
{
no=no%9;
if(no==0)
printf("sum = 9");
else
printf("sum = %d", no);
}
getch();
}
| Is This Answer Correct ? | 9 Yes | 5 No |
Post New Answer View All Answers
Here is a good puzzle: how do you write a program which produces its own source code as output?
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
What is the value of uninitialized variable in c?
what is the basis for selection of arrays or pointers as data structure in a program
Why is c not oop?
What is the sizeof () operator?
How do you use a pointer to a function?
What are qualifiers and modifiers c?
What does the function toupper() do?
Explain what are binary trees?
When is a “switch” statement preferable over an “if” statement?
What is character constants?
What is calloc malloc realloc in c?
What is %g in c?
What is function definition in c?