Program to find the sum of digits of a given number until
the sum becomes a single digit

Answer Posted / sohini khan

main()
{int n,p,s=0;
while(n>0)
{
p=n%10;
s=s+p;
n=n/10;
}
printf("%d",s);
getch(),
}

Is This Answer Correct ?    29 Yes 43 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

explain what is an endless loop?

615


How do you determine the length of a string value that was stored in a variable?

652


What is the difference between exit() and _exit() function?

610


What is a static variable in c?

671


What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?

908






What is the method to save data in stack data structure type?

611


What does %p mean c?

634


Add Two Numbers Without Using the Addition Operator

357


What do you mean by dynamic memory allocation in c?

656


What is array of structure in c programming?

759


What is bash c?

562


Explain what is meant by 'bit masking'?

646


which type of aspect you want from the student.

1704


What is && in c programming?

683


What is maximum size of array in c?

586