Computer Science, asked by Astrophysicist, 1 year ago

WAP in java to accept a sentence from the user and then print the words in reverse order without using array and pls provide suitable explanation of how the program works.

Answers

Answered by chaitanyakrishn1
2
Import java.util.Scanner 

System.out.println (enter a sentence);
String s =in.nextLine ();
Int l=s.length ();
String z=" ";
for (int m=0; m <l; m++)
{
char c=s.charAt (m);
If(c!=32)
z=z+c;
Else
{
Int l2 =z.length ();
String b=" ";
for(int j=l2-1; j > 0; j--);
{
char c3=z.charAt (j);
b =b+c3;
System.out.println (b);
z=" ";
}
}
}
}
}

chaitanyakrishn1: I hope a brainiest for writing the answer
Similar questions