Python Program:

- To reverse a number

Example:

User Input: 153

Output:
Your reversed number : 351

num=int(input("Enter your number : "))
reverse = 0
while num!=0 :
  reverse=reverse*10+num%10
  num=int(num/10)
print("Your reversed number : ",reverse)

Output:

  Enter Your number : 1132
  Your reversed number : 2311
Program
number

Main Logic :

while num!=0 :
  reverse=reverse*10+num%10
  num=int(num/10)

Example :

Initially, reverse=0
Let num=15,

Now, reverse=0,num=15 [still 'num' not equal to ZERO]
reverse = 0*10+15%10; // = 5
num=15/10;  // =1;

Now, reverse=5,num=1 [still 'num' not equal to ZERO]
reverse=5*10+1%10;   // =51
num=1/10;  // =1

Now num=0
So finally your reverse number which is 51
Concept

Coming Soon !

Quick
Tutorial

Quote

Make bold choices and make mistakes. It’s all those things that add up to the person you become.