Created
April 5, 2016 04:48
-
-
Save batmantec/24c127e27fef36fed4d21c167b529ec5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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