Skip to content

Instantly share code, notes, and snippets.

@batmantec
Created April 5, 2016 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save batmantec/24c127e27fef36fed4d21c167b529ec5 to your computer and use it in GitHub Desktop.
Save batmantec/24c127e27fef36fed4d21c167b529ec5 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
using std::string;
using std::cin;
using std::cout;
using std::endl;
void checkPal(string word){
int i;
for(i=0; i<(word.size()/2); i++){
if(word[i]!=(word[word.size()-1-i]))
break;
}
if(i==(word.size()/2))
cout << word <<" is a palindrome"<<endl;
else
cout << word <<" is NOT a palindrome"<<endl;
}
int main(){
string word;
cout << "What word you want to check (please enter all in lower case): ";
cin >> word;
checkPal(word);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment