Question: One by one pop all characters from stack and put them back to string. 3 . Reverse a number using stack - Given a number,

One by one pop all characters from stack and put them back to string.
3. Reverse a number using stack - Given a number, write a program to reverse this number using stack.
Examples:
Input : 365
Output : 563
Input : 6899
Output : 9986
Notes on problem 3
The idea to do this is to extract digits of the number and push the digits on to a stack. Once all of the digits of the number are pushed to the stack, we will start popping the contents of stack one by one and form a number.
As stack is a LIFO data structure, digits of the newly formed number will be in reverse order.
 One by one pop all characters from stack and put them

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!