Write a Java program to find Reverse of a number

By | 09.02.2017

Java program to find Reverse of a number

Java Program to reverse a number in Java Programming, you have to ask to the user to enter the number.

Start reversing the number, first make a variable rev and place 0 to rev initially, and make one more variable say rem.

Now place the modulus of the number to rem and place rev*10+rem to the variable rev, now divide the number with 10 and continue until the number will become 0.




import java.util.Scanner;
public class Reverse_Number
   public static void main(String args[])
      int n, reverse = 0;
      System.out.println("Enter the number to reverse");
      Scanner in = new Scanner(System.in);
      n = in.nextInt();
      while( n != 0 )
          reverse = reverse * 10;
          reverse = reverse + n%10;
          n = n/10;
      System.out.println("Reverse of entered number is "+reverse);




Enter the number to reverse
Reverse of entered number is 54321


5 1 vote
Article Rating
Category: Java Programming Number Programs Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Notify of

1 Comment
Newest Most Voted
Inline Feedbacks
View all comments

Brother, your explanation and source code are totally different.