Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- //
- //
- #include <iostream>
- #include <cstring>
- using namespace std;
- void isPalindrome();
- int main()// this is the main function
- {
- cout << "Please enter a word: ";
- isPalindrome();
- return 0;
- }//end of main function
- int get_word()
- {
- char word[100];
- cout << "Please enter a word: ";
- cin >> word;
- }
- void isPalindrome()
- {
- int is_a_palindrome,
- length;
- char word[100];
- cin >> word;
- length = strlen(word);
- for (int i = 0; i < length/2 ; i++)
- {
- if (word[i] == word[length - 1 - i])
- {
- isPalindrome = 1;
- }
- else
- {
- isPalindrome = 0;
- }
- }
- if (isPalindrome == 1)
- {
- cout << "The word you entered, '" << word << "' is a palindrome." << endl;
- }
- else
- {
- cout << "The word you entered, '" << word << "' is not a palindrome." << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement