Program to find the sum of digits of a given number until
the sum becomes a single digit
Answer Posted / rama krishna sidhartha
int n = 1234; //any numer of you want sum
int sum = 0;
void main()
{
clrscr();
while (n > 0)
{
int p = n % 10;
sum = sum + p;
n = n / 10;
}
printf("%d",sum);
getch();
}
Is This Answer Correct ? | 49 Yes | 75 No |
Post New Answer View All Answers
What does the characters “r” and “w” mean when writing programs that will make use of files?
What is structure and union in c?
What is a protocol in c?
what are non standard function in c
What is array of structure in c?
Is array name a pointer?
How many levels of pointers have?
What are the 5 organizational structures?
Write a program to swap two numbers without using third variable?
What is logical error?
Why is c so powerful?
How can you increase the allowable number of simultaneously open files?
Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.
please give me some tips for the placement in the TCS.
What is I ++ in c programming?