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

What does the characters “r” and “w” mean when writing programs that will make use of files?

864


What is structure and union in c?

606


What is a protocol in c?

567


what are non standard function in c

1443


What is array of structure in c?

609






Is array name a pointer?

610


How many levels of pointers have?

602


What are the 5 organizational structures?

573


Write a program to swap two numbers without using third variable?

821


What is logical error?

610


Why is c so powerful?

693


How can you increase the allowable number of simultaneously open files?

603


Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.

713


please give me some tips for the placement in the TCS.

1641


What is I ++ in c programming?

632