Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. //
  2. //
  3. //
  4. #include <iostream>
  5. #include <cstring>
  6. using namespace std;
  7.  
  8. void isPalindrome();
  9.  
  10. int main()// this is the main function
  11. {
  12.  
  13. cout << "Please enter a word: ";
  14. isPalindrome();
  15.  
  16. return 0;
  17. }//end of main function
  18.  
  19. int get_word()
  20. {
  21. char word[100];
  22.  
  23. cout << "Please enter a word: ";
  24. cin >> word;
  25. }
  26.  
  27. void isPalindrome()
  28. {
  29. int is_a_palindrome,
  30. length;
  31. char word[100];
  32.  
  33. cin >> word;
  34. length = strlen(word);
  35.  
  36. for (int i = 0; i < length/2 ; i++)
  37. {
  38. if (word[i] == word[length - 1 - i])
  39. {
  40. isPalindrome = 1;
  41. }
  42. else
  43. {
  44. isPalindrome = 0;
  45. }
  46. }
  47.  
  48. if (isPalindrome == 1)
  49. {
  50. cout << "The word you entered, '" << word << "' is a palindrome." << endl;
  51. }
  52. else
  53. {
  54. cout << "The word you entered, '" << word << "' is not a palindrome." << endl;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement