File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ // to check if a string is palindrome or not
2+
3+ #include < bits/stdc++.h>
4+ using namespace std ;
5+
6+ int main ()
7+ {
8+ string s;
9+ getline (cin, s);
10+ char ch;
11+ string str;
12+ for (int i = 0 ; i < s.length (); i++)
13+ {
14+ ch = s.at (i);
15+ if (ch != ' ' )
16+ str = ch+str;
17+ }
18+ if (str == s)
19+ cout<<" Palindrome" <<endl;
20+ else
21+ cout<<" Not Palindrome" <<endl;
22+ return 0 ;
23+ }
Original file line number Diff line number Diff line change 1+ import java .util .*;
2+ class palindrome
3+ {
4+ public static void main ()
5+ {
6+ Scanner sc = new Scanner (System .in );
7+ System .out .println ("Enter your word" );
8+ String str = sc .nextLine ();
9+ String s = str ;
10+ String st = "" ;
11+ char ch ;int i ;
12+ for (i =0 ;i <str .length ();i ++)
13+ {
14+ ch = str .charAt (i );
15+ st = ch +st ;
16+ }
17+ if (s .equalsIgnoreCase (st ))
18+ System .out .println ("Palindrome word" );
19+ else
20+ System .out .println ("Not a Palindrome word" );
21+ }
22+ }
23+
You can’t perform that action at this time.
0 commit comments