Program which reads a four digit number and print a number which is reverse of it.

import java.io.*;
class hello
{    public static void main(String asd[])throws IOException
{
BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
int n,a,b,c,d;
String num;
System.out.println("Enter the number::");
num=in.readLine();
n=Integer.parseInt(num);
a=n%10;
n=n/10;
b=n%10;
n=n/10;
c=n%10;
n=n/10;
d=n%10;
n=n/10;
System.out.println("Reversed Digit is= "+a+b+c+d);
}
   }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s