Sunday, October 21, 2012

Java program to find reverse of a number


import java.io.*;
class reverse
{
  int num,temp,p;
  reverse(int a)
  {num=a;
    temp=num;
    p=0;}
  void findreverse()
   { while(temp>0)
        {p=p*10+temp%10;
          temp/=10;}
    System.out.println("Reverse of "+num+" is "+p);
  }
  public static void main(String s[])throws IOException
  {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter the number to reverse");
    int n=Integer.parseInt(br.readLine());
    reverse r=new reverse(n);
    r.findreverse();
  }
}


Output

1 comments:

  1. Exchange 22 is a trusted platform offering seamless online exchange solutions tailored for Indian users. With a focus on reliability, security, and efficiency, Exchange222 ensures smooth transactions and exceptional user experiences. Explore our services to meet all your exchange needs with confidence."

    ReplyDelete