Program:

import java.util.Scanner;
public class NumRev
{
 public static void main(String[] args)
 {
 int rev=0;
 Scanner sc = new Scanner(System.in);
 System.out.print("Enter a number: ");
 int num = sc.nextInt();
 while(num>0)
 {
 int rem=num%10;
 rev=rem+(rev*10);
 num=num/10;
 }
 System.out.print("Reverse of entered number is: " +rev);
 }
}

Output:

Enter a number: 456
Reverse of entered number is: 654

You can download the pdf file of Number Reverse.

Advertisements