// this program reverses a three digit number
import javax.swing.*;
public class basicss
{
public static void main(String[] args)
{
int a1,a2,a3,rev,n;
n=Integer.parseInt(JOptionPane.showInputDialog("enter a three digit number"));
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);
}
}
import javax.swing.*;
public class basicss
{
public static void main(String[] args)
{
int a1,a2,a3,rev,n;
n=Integer.parseInt(JOptionPane.showInputDialog("enter a three digit number"));
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 a three digit number 123
reverse = 321
No comments:
Post a Comment
SAY HELLO!!