Program to find the sum of digits of a given number until
the sum becomes a single digit
Answer Posted / ashutosh shashi
int n = 123456789; //any numer of you want sum
int sum = 0;
while (n > 0)
{
int p = n % 10;
sum = sum + p;
n = n / 10;
if(n==0 && sum>9)
{
n=sum;
sum=0;
}
}
printf("%d",sum);
| Is This Answer Correct ? | 157 Yes | 63 No |
Post New Answer View All Answers
A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles
The statement, int(*x[]) () what does in indicate?
What is the process of writing the null pointer?
differentiate built-in functions and user – defined functions.
Are comments included during the compilation stage and placed in the EXE file as well?
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
Difference between pass by reference and pass by value?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
How to define structures? ·
How can I implement sets or arrays of bits?
What do you mean by c what are the main characteristics of c language?
is it possible to create your own header files?
How is pointer initialized in c?
What is %s and %d in c?
Why do we use static in c?