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
How can I change their mode to binary?
Why c is called a mid level programming language?
Explain how do you view the path?
How can you return multiple values from a function?
What is the difference between malloc() and calloc() function in c language?
What does malloc () calloc () realloc () free () do?
What is header file definition?
the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b
What is pass by reference in c?
Explain what is the difference between a string and an array?
What does %d do?
Explain how can you check to see whether a symbol is defined?
What is int main () in c?
Write the control statements in C language
What is struct node in c?