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
Tell me what is null pointer in c?
An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?
Why clrscr is used after variable declaration?
Why is structure important for a child?
Do you know the difference between exit() and _exit() function in c?
Can a variable be both static and volatile in c?
What are high level languages like C and FORTRAN also known as?
In c programming language, how many parameters can be passed to a function ?
general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only
What is substring in c?
What are the difference between a free-standing and a hosted environment?
What is function and its example?
Why #include is used in c language?
How can I find the modification date of a file?
What is extern storage class in c?