Write a program to check whether an entered word is palindrome or not. .
Answers
Answered by
3
Answer:
Program:-
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
String st,st1="";
int p;
System.out.println("Enter a String");
st=in.nextLine();
p=st.length();
char ch;
for(int i=p-1;i>=0;i--)
{
ch=st.charAt(i);
st1=st1+ch;
}
if(st.equals(st1))
System.out.println("It is a palindrome String");
else
System.out.println("It is not a palindrome String");
}
}
Refer to the attachment for the output.
A palindrome string is a string in which the string after reversing the string is equal to the orignal string.
Ex madam,mom
Attachments:
Similar questions