Print the reverse of a number.

In this program, we will print the reverse of a number.

Steps to solve the program
  1. Take a number as input through the user and create a variable rev and assign its value equal to 0.
  2. Use a while loop to find the reverse of a number.
  3. While num is greater than 0 divide the number by 10 using to find the remainder.
  4. Multiply the rev by 10 and add the remainder to it.
  5. Now divide number by 10 using //.
  6. Print the final output.
				
					n = int(input("Enter a number: "))
rev = 0

while n>0:
    r = n%10
    rev = (rev*10) + r
    n = n // 10

print("Reverse number: ",rev)
				
			

Output :

				
					Enter a number: 256
Reverse number:  652
				
			

calculate the product of digits of a number

check whether a number is a palindrome or not

Leave a Comment