Skip to content

Commit f202d63

Browse files
Merge pull request #59 from satyam878/satyam1
Palindrome
2 parents 084a81a + 4c91054 commit f202d63

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//Created a program to check whether given string is palindrome or not.
2+
import java.util.*;
3+
public class Main
4+
{
5+
public static void main(String[] args) {
6+
Scanner sc=new Scanner(System.in);
7+
System.out.println("Enter a String");
8+
String s=sc.nextLine();
9+
int l=s.length();
10+
int temp=0;
11+
for(int i=0,j=l-1;i<=j;i++,j--) //Traverse string from start and end
12+
{
13+
if(s.charAt(i)!=s.charAt(j)) //Check Each Character From start and end
14+
{
15+
System.out.println("Not Palindrome"); //if condition fails it displays not palindrome
16+
temp=1;
17+
break;
18+
}
19+
}
20+
if(temp==0) //if abpve condition does not satisfies then print palindrome
21+
System.out.println("Palindrome");
22+
}
23+
}

0 commit comments

Comments
 (0)