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 the difference between malloc() and calloc()?
What is the argument of a function in c?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)
List the different types of c tokens?
What is the purpose of main() function?
Wt are the Buses in C Language
Apart from dennis ritchie who the other person who contributed in design of c language.
What is void pointers in c?
Where can I get an ansi-compatible lint?
Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.
What is union and structure?
What are the main characteristics of c language describe the structure of ac program?
string reverse using recursion
Is null always equal to 0(zero)?