Skip to content

Instantly share code, notes, and snippets.

@jaideepjagyasi
Created August 12, 2017 13:20
Show Gist options
  • Save jaideepjagyasi/c43442c45995df1740fb9ba53411ba3b to your computer and use it in GitHub Desktop.
Save jaideepjagyasi/c43442c45995df1740fb9ba53411ba3b to your computer and use it in GitHub Desktop.
#include<iostream>
#include<string>
using namespace std;
bool isPalindrome(string str,int len);
int main(){
string s;
cin>>s;
if(isPalindrome(s,s.length())){
cout<<"true"<<endl;
}
else
cout<<"false"<<endl;
}
bool isPalindrome(string str,int len){
bool flag=false;
int i=0;
while(i<=len-1){
if(str[i]==str[len-1]){
flag=true;
i++;
len--;
}
else{
flag=false;
break;
}
}
return flag;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment