We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b3030be + ab6cc16 commit 1c2df83Copy full SHA for 1c2df83
StringPalindrome.cpp
@@ -0,0 +1,29 @@
1
+#include <iostream>
2
+using namespace std;
3
+
4
+char str1[20];
5
+int i, length;
6
+int flag = 0;
7
8
+int main() {
9
10
+ cout << "Enter a string: ";
11
+ cin >> str1;
12
13
+ length = strlen(str1);
14
15
+ for (i = 0; i < length; i++) {
16
+ if (str1[i] != str1[length - i - 1]) {
17
+ flag = 1;
18
+ break;
19
+ }
20
21
22
+ if (flag) {
23
+ cout << str1 << " is not a palindrome" << endl;
24
25
+ else {
26
+ cout << str1 << " is a palindrome" << endl;
27
28
+ return 0;
29
+}
0 commit comments