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


Please Help Members By Posting Answers For Below Questions

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

683


What is an lvalue in c?

692


Why do we use int main?

602


What is the use of function in c?

709


Does free set pointer to null?

555






What is auto keyword in c?

787


What is unsigned int in c?

551


Explain how do you list files in a directory?

614


What do you mean by Recursion Function?

627


What does stand for?

590


How to compare array with pointer in c?

615


Why do we use stdio h and conio h?

631


Write a Program to accept different goods with the number, price and date of purchase and display them

5441


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

1425


How are strings stored in c?

590