From 7a4bd82ba3c1ae92b61d06a4f56a0d6c1e433068 Mon Sep 17 00:00:00 2001 From: Govind Sangal <115642308+sangalgovind@users.noreply.github.com> Date: Sat, 15 Oct 2022 20:42:05 +0530 Subject: [PATCH] palindrome.cpp --- palindrome.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 palindrome.cpp diff --git a/palindrome.cpp b/palindrome.cpp new file mode 100644 index 0000000..1b1e4ae --- /dev/null +++ b/palindrome.cpp @@ -0,0 +1,20 @@ +#include +#include +using namespace std; +int main() +{ + char str1[20], str2[20]; + int i, j, len = 0, flag = 0; + cout << "Enter the string : "; + gets(str1); + len = strlen(str1) - 1; + for (i = len, j = 0; i >= 0 ; i--, j++) + str2[j] = str1[i]; + if (strcmp(str1, str2)) + flag = 1; + if (flag == 1) + cout << str1 << " is not a palindrome"; + else + cout << str1 << " is a palindrome"; + return 0; +}