Java Code to Reverse a Number

Reverse a Number using Java


import java.util.Scanner; 

class ReverseNumber { 
public static void main(String args[]) { 

int num=0; 
int revnum =0; 

System.out.println("Input your number and press enter: "); 

Scanner in = new Scanner(; 
num = in.nextInt(); 

while( num != 0 ) { 
revnum = revnum * 10; 
revnum = revnum + num%10; 
num = num/10; } 

System.out.println("Reverse of input number is: "+revnum);
} }

Click here to run this code

More Free Code Examples:

Java Code to Reverse a String

Java Current Time and Date Program

Javascript Easy Battleship Game


Popular posts from this blog

Multi-tap Keypad Text Entry

HTML5 Crossword 1