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
Why is c called c?
Explain how can I right-justify a string?
What does. int *x[](); means ?
How will you divide two numbers in a MACRO?
What are the rules for the identifier?
illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question
Why is c still so popular?
What is character set?
Why can't I perform arithmetic on a void* pointer?
Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250
Which driver is a pure java driver
What is the difference between #include and #include 'file' ?
i got 75% in all semester am i eligible for your company
How can I do serial ("comm") port I/O?
What is %lu in c?