Answer Posted / mani bhowmik
void main()
{
int num, temp;
for(;;) {
printf("Enter number:");
scanf("%d",&num);
if(num == 0) break;
while(num) {
temp = num%10;
num = num/10;
printf("%d", temp);
}
printf("\n");
}
getche();
}
So any number will be reversed here. 12345 is five digit
number. Using while we can generalize the number of digits.
The continuous loop is ended when 0 is entered.
| Is This Answer Correct ? | 1 Yes | 5 No |
Post New Answer View All Answers
Explain how can a program be made to print the name of a source file where an error occurs?
What is the use of pointers in C?
What are the advantages of using linked list for tree construction?
What are the types of variables in c?
How do you list a file’s date and time?
What does c mean in standard form?
Why do we use & in c?
What are the application of void data type in c?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
How can you tell whether a program was compiled using c versus c++?
What is declaration and definition in c?
How can I remove the leading spaces from a string?
Write a program to reverse a string.
What is c language and why we use it?
What is the difference between declaring a variable by constant keyword and #define ing that variable?