Java Program to Swap/Reverse Two Digit Numbers

Below is a simple java program to swap or reverse two digit number. When the program will execute, it will enable the user to enter the two digit number to reversed.

Here is the program :

import java.util.Scanner;
public class Reverse {
public static void main ( String args [])
Scanner s = new Scanner(;
int a,b,c,d;
System.out.println(“Enter the Number to be reversed”);
a= s.nextInt();
System.out.println(“The reverse of number is : ” +c);




Output : Enter the Number to be reversed : 89

The Reverse of Number is : 98

The above program will not reverse digits greater than two.

Add Comment