Enter any integer number as an input. After that we use modulus and division operation respectively to generate output.
Here is the source code of the Java Program to Reverse a Given Number. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
public class Reverse_Number
public static void main(String args)
int m, n, sum = 0;
Scanner s = new Scanner(System.in);
System.out.print("Enter the number:");
m = s.nextInt();
while(m > 0)
n = m % 10;
sum = sum * 10 + n;
m = m / 10;
$ javac Reverse_Number.java $ java Reverse_Number Enter the number:567 Reverse:765
Sanfoundry Global Education & Learning Series – 1000 Java Programs.