Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Lab3.4.Palindrome.cpp : Defines the entry point for the console application.
- // A program that checks if a word is a palindrome
- // Written by Louise Mao ID 10948994
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- using namespace std;
- bool palindrome(string word) {
- bool flag;
- int length = word.length()
- for (int i = 0; i < (length / 2); i++) {
- if (word[i] == word[length - i]) {
- Flag = true;
- }
- else {
- flag = false;
- break;
- }
- }
- return flag;
- }
- int main()
- {
- string word;
- bool n;
- cout << "Enter a word" << endl;
- cin >> word;
- n = palindrome(word);
- cout << n << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement