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
Explain how can you be sure that a program follows the ansi c standard?
What are the types of pointers in c?
What does %c mean in c?
What is the meaning of 2d in c?
What is the difference between struct and union in C?
What is a void pointer in c?
If I have a char * variable pointing to the name of a function ..
What is the most efficient way to store flag values?
in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above
Explain how are 16- and 32-bit numbers stored?
Is null always defined as 0(zero)?
What are predefined functions in c?
Is struct oop?
code for find determinent of amatrix
What is c method?