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
What are register variables in c?
what is the different bitween abap and abap-hr?
How to draw the flowchart for structure programs?
Are bit fields portable?
int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer
What do you mean by a sequential access file?
Does c have circular shift operators?
State two uses of pointers in C?
What is meant by type specifiers?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
What is hashing in c language?
What does 1f stand for?
Compare array data type to pointer data type
What is the use of volatile?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?