Program to find the sum of digits of a given number until
the sum becomes a single digit
Answer Posted / suvabrata das
#include<stdio.h>
#include<conio.h>
void main()
{
int n,c=0,r,i;
clrscr();
printf("enter no.");
scanf("%d",&n);
while(n>0)
{
{
r=n%10;
c=c+r;
n=n/10;
}
if(c>9)
{
n=c;
c=0;
}
}
printf("%d",c);
getch();
}
| Is This Answer Correct ? | 58 Yes | 34 No |
Post New Answer View All Answers
Does c have function or method?
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What is far pointer in c?
In a switch statement, what will happen if a break statement is omitted?
Difference between pass by reference and pass by value?
I need a sort of an approximate strcmp routine?
Is c high or low level?
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
Where static variables are stored in c?
What is call by reference in functions?
What is the benefit of using an enum rather than a #define constant?
Explain how can I avoid the abort, retry, fail messages?
can anyone suggest some site name..where i can get some good data structure puzzles???
What is chain pointer in c?
Can static variables be declared in a header file?