Monday 9 June 2014

Program to find the reverse of a three digit number

// this program reverses a three digit number
import javax.swing.*;
public class reverses
{
public static void main(String[] args)
{
int a1,a2,a3,rev,n;
n=Integer.parseInt(JOptionPane.showInputDialog("enter the no to find reverse"));
a1=n%10;
n=n/10;
a2=n%10;
n=n/10;
a3=n%10;
rev=a1*100+a2*10+a3;
System.out.print("reverse = "+rev);
}
}
output:
enter the no to find reverse 345
reverse = 543

No comments:

Post a Comment

SAY HELLO!!