I was viewing the practice problem section and decided to give a go at them, anyways, this is my Palindrome dector code. Could someone just take a look at it and explain to me if there is a better way to execute this problem?

- michael

// Palindrome check by Michael Turbe (c) 2009

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(void)
{
	// system config
	system("TITLE Palindrome");

	// variables
	string User_Input;
	string Input_Reverse;

	string::iterator Position;

	bool StartOver;

	// loop allows multiple takes on program without restart
	do
	{
		StartOver = false;
		system("CLS");

		cout << "Palindrome Check" << endl;
		cout << "----------------" << endl << endl;
		cout << "Enter a word or series of numbers." << endl << endl;

		cin >> User_Input;

		string Input_Reverse(User_Input.begin(), User_Input.end());

		reverse(Input_Reverse.begin(), Input_Reverse.end());

		if(User_Input == Input_Reverse)
		{
			cout << endl << User_Input << " is a Palindrome." << endl << endl;
		}
		else
		{
			cout << endl << User_Input << " and " << Input_Reverse << " are not the same." << endl << endl;
		}
		
		cout << "Would you like to start over? 1 - Yes, 0 - No" << endl;
		cout << "Enter choice and press ENTER." << endl;
		cin >> StartOver;
	}
	
	while(StartOver == true);

}
Salem commented: Congrats on using code tags on your first post, very few manage it. +26

Your answer seems fine to me.

There are many different ways of solving the problem, but whether any of them are "better" would be a subjective statement IMO.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.