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

What is c mainly used for?

593


When is the “void” keyword used in a function?

826


What is the difference between int main and void main?

569


How do you determine whether to use a stream function or a low-level function?

645


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

2787






Is register a keyword in c?

629


What is derived datatype in c?

627


Linked lists -- can you tell me how to check whether a linked list is circular?

639


What is a shell structure examples?

586


What are the benefits of c language?

641


What are the types of functions in c?

568


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

1836


What is merge sort in c?

640


What are the functions to open and close the file in c language?

589


Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.

1759