import java.io.*;
class reversenum
{
int num,dup,rev,rem;
reversenum()
{
rev=rem=0;
}
void get()throws IOException
{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number : ");
num=Integer.parseInt(br.readLine());
dup=num;
while(dup>0)
{
rem=dup%10;
rev=rev*10+rem;
dup=dup/10;
}
}
void disp()
{
System.out.println("\nThe reverse of " +num+" is "+rev);
}
public static void main(String[] args)throws IOException
{
reversenum r=new reversenum();
r.get();
r.disp();
}
}
0 comments:
Post a Comment