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
An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array
What is an lvalue in c?
Why do we use int main?
What is the use of function in c?
Does free set pointer to null?
What is auto keyword in c?
What is unsigned int in c?
Explain how do you list files in a directory?
What do you mean by Recursion Function?
What does stand for?
How to compare array with pointer in c?
Why do we use stdio h and conio h?
Write a Program to accept different goods with the number, price and date of purchase and display them
GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA
How are strings stored in c?