Skip to content

Commit 883e18c

Browse files
committed
C++ code to check string palindrome
1 parent f0f5dce commit 883e18c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Palindrome/StringPalindrome.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}

0 commit comments

Comments
 (0)