Java program to Reverse the given number

Friday, February 4th, 2011
1
2
3
4
5
6
7
8
9
10
11
12
class Reverse{
	public static void main(String args[]){
		int num = Integer.parseInt(args[0]); //take argument as command line
		int remainder, result=0;
		while(num>0){
			remainder = num%10;
			result = result * 10 + remainder;
			num = num/10;
		}
		System.out.println("Reverse number is : "+result);
	}
}
Avatar of surajk

Author Name :
surajk

Total : 3 Comments


3 Responses to “Java program to Reverse the given number”

  1. kmc says:

    late binding.. :)

  2. shreyas says:

    when compiled sayas “exception in thread “main” java.lang.arrayindexoutofboundsexception:0 at Reverse.main “

  3. raj says:

    sorry to say your source code is not usefull because the adds cover your code its not able to see your code.

Leave a Reply

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: