How to print a number in reverse order in java

Wednesday, March 18, 2009

import java.io.*; class trye { public static void main (String args[])throws IOException { String a; BufferedReader ob=new BufferedReader(new InputStreamReader(System.in) ); System.out.print("Enter your number:"); a=ob.readLine(); int d=Integer.parseInt(a); int n=d; System.out.print("The number in reversr order:"); while( n!=0) { int m=n%10; n=n/10; System.out.print(m); } System.out.println(""); } }

0 comments:

Visitors

PlugIn.ws - Free Hit Counter, Web Site Statistics, Traffic Analysis

  © Blogger template Leaving by Ourblogtemplates.com 2008

Back to TOP