♣♣♣ WRITE A PROGRAM TO REVERSE
THE STRING. ♣♣♣
import java.io.*;
class pro2
{
public
static void main(String args[]) throws IOException
{
String
s1;
InputStreamReader
a=new InputStreamReader(System.in);
BufferedReader
b=new BufferedReader(a);
System.out.print("Enter
any string : ");
s1=b.readLine();
int
cnt=s1.length();
System.out.println("Real String = "+s1);
System.out.print("Reverse
String= ");
while(cnt>0)
{
System.out.print(s1.charAt(cnt-1));
cnt--;
}
System.out.println();
}
}
OUTPUT :-
Enter any
string : KAPIL
Real String = KAPIL
Reverse
String = LIPAK
No comments:
Post a Comment