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
What are pointers? What are different types of pointers?
What is the auto keyword good for?
Why do we use int main instead of void main in c?
Why c is called a mid level programming language?
What are the advantages and disadvantages of pointers?
What is pointers in c?
When should structures be passed by values or by references?
What do you mean by scope of a variable in c?
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
Does c have class?
Explain how do you convert strings to numbers in c?
How do shell structures work?
What is a built-in function in C?
What is the explanation for cyclic nature of data types in c?
The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this