convert 12345 to 54321 withoutusing strig

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


Please Help Members By Posting Answers For Below Questions

How can I get random integers in a certain range?

604


Explain what does it mean when a pointer is used in an if statement?

605


Is there anything like an ifdef for typedefs?

692


Why is c not oop?

531


What's a good way to check for "close enough" floating-point equality?

615






What are pointers? What are stacks and queues?

569


Explain the meaning of keyword 'extern' in a function declaration.

707


How many loops are there in c?

569


What is property type c?

594


What extern c means?

525


What is extern variable in c with example?

529


Explain what is a program flowchart and explain how does it help in writing a program?

637


Explain the bubble sort algorithm.

630


i have a written test for microland please give me test pattern

2170


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

604