Given a word the task is to reverse the word.
Example: Consider the word “Ipsum”. The reversed word will be “muspI”.
Java
import java.util.*;
class WordReverse
{
public static void main(String Args[])
{
int l=0;
String str="",rev="";
char ch=' ';
Scanner sc=new Scanner(System.in);
System.out.print("Enter a word: ");
str=sc.next();
str=str.trim();
l=str.length();
for(int i=0;i<l;i++)
{
ch=str.charAt(i);
rev=ch+rev;
}
System.out.println("Reverse of the word is: "+rev);
}
}Java