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 is pointer to pointer in c?
What are categories used for in c?
Why do we need a structure?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
Which built-in library function can be used to match a patter from the string?
What is an array in c?
How can I discover how many arguments a function was actually called with?
How #define works?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Why is structure padding done in c?
What are runtime error?
What is the difference between āgā and āgā in C?
What does return 1 means in c?
Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.