Program to find the sum of digits of a given number until
the sum becomes a single digit
Answer Posted / sanjay m
#include<stdio.h>
#include<conio.h>
void main()
{
unsigned int n,c=0,r,i,S=0;
clrscr();
printf("enter no.");
scanf("%d",&n);
while(n>0)
{
{
r=n%10;
c=c+r;
n=n/10;
}
if(c>9)
{
int X=c%10;
int Y=c/10;
S=X+Y;
}
}
if(c<10)
printf("%d",c);
else
printf("%d",S);
getch();
}
| Is This Answer Correct ? | 13 Yes | 14 No |
Post New Answer View All Answers
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
Is return a keyword in c?
What is the difference between class and object in c?
What is a #include preprocessor?
What happens if you free a pointer twice?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
What's the best way of making my program efficient?
What happens if a header file is included twice?
What is the best style for code layout in c?
hi send me sample aptitude papers of cts?
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 data type long in c?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What’s the special use of UNIONS?
what is the format specifier for printing a pointer value?