this pgm ll get a string form u and displays the string length then reverse string is display
import java.util.Scanner;
public class reverse_string{public static void main(String args[]){
String s;
Scanner in=new Scanner(System.in);
System.out.println("enter the string");s=in.nextLine();
int len=s.length();
System.out.println("length of string is"+len);int i;
while(len>0){
char yo=s.charAt(len-1);System.out.print(yo);len=len-1;}
}}
No comments:
Post a Comment