From 721b6425e3ce95a2cde92060e2ad73c1c4da66e7 Mon Sep 17 00:00:00 2001 From: aman-sagar <48382607+aman-sagar@users.noreply.github.com> Date: Fri, 17 Apr 2020 20:03:20 +0530 Subject: [PATCH] Create SolutionByAman.cpp --- .../SolutionByAman.cpp | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Basic/Check if A String is Palindrome or Not/SolutionByAman.cpp diff --git a/Basic/Check if A String is Palindrome or Not/SolutionByAman.cpp b/Basic/Check if A String is Palindrome or Not/SolutionByAman.cpp new file mode 100644 index 0000000..72fe5e0 --- /dev/null +++ b/Basic/Check if A String is Palindrome or Not/SolutionByAman.cpp @@ -0,0 +1,34 @@ +#include +#include +using namespace std; + +int main() { + // your code goes here + string s; + cin>>s; + int n=s.length(); + + int flag=0; + for(int i=0;i<=n;i++) + + { + if(s[i]==s[n-1-i]) + { + flag=1; + } + else + { + flag=0; + break; + } + } + if(flag==1) + { + cout<<"given string is palindrome"; + } + else + { + cout<<"given string is not palindrome"; + } + return 0; +}