Input an ASCII code, reverse the ASCII code and
display the equivalent character
e.g: Entered value: 98
Reverse: 89
Output: Y
import java.util.*;
class Char5
{
Int n, rev=0;
Scanner sc=new Scanner(System.in);
void take()
{
System.out.print(“\nEnter the ASCII Code:”);
n=sc.nextInt();
if(n%10==0)
{
System.out.print(“\n
Reversing not possible.”);
System.exit(0);
}
while(n>0)
{
rev=rev*10+n%10;
n=n/10;
}
System.out.print((char)rev);
}
public static void main(String args[])
{
Char5 ob=new Char5 ();
ob.take ();
}
No comments:
Post a Comment