All pastes #456851 Raw Edit

Mine

public text v1 · immutable
#456851 ·published 2007-04-25 01:21 UTC
rendered paste body
#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;

int main()
{

	const int SIZE = 80;
	char Palindrome[SIZE];
	int i = 0; //index of array
	int numLetters = 0; //counter 
	char revPalindrome[SIZE];

	//prompt the user
	cout << "Type to see if your word, phrase, or sentance is a palendrome.\n";
	cin.getline(Palindrome, SIZE);

	//echo input
	cout << "\nEchoing input... \n";
	cout << Palindrome << endl;

	//count the number of symbols typed
	int strlen(Palindrome[SIZE]);
	cout << "\nThere are " << numLetters << " letters in sentence.\n";

	//put the null character in the same index position as sentence
	revPalindrome[numLetters] = '\0';

	//start reversing the letters 1 element at a time
	for(int j = 0; j < numLetters; j++)
	{
		revPalindrome[j] = Palindrome[numLetters - 1 - j];
	}
	
	//output the reversed string
	cout << revPalindrome << endl;

	if (Palindrome == revPalindrome)
		cout << "You have a Palindrome!" << endl;
	else
		cout << "You do not have a palindrome!" << endl;

	return 0;
}