#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string normal;
string normal_before_func;
string reverse;
string reverse_before_func;
string temp;
char ch;
int i = 0;
int w = 0;
int strcount = 0;
cout << "Please Enter A String: ";
getline(cin,normal);
normal_before_func = normal;
for(int w = normal.length()-1; w > -1; w--)
{
reverse_before_func.push_back(normal[w]);
}
while(i != normal.length())
{
switch(normal[i])
{
case ' ':
normal.erase(i,1);
i--;
break;
case '!':
normal.erase(i,1);
i--;
break;
case '.':
normal.erase(i,1);
i--;
break;
case ',':
normal.erase(i,1);
i--;
break;
case ';':
normal.erase(i,1);
i--;
break;
case ':':
normal.erase(i,1);
i--;
break;
case '(':
normal.erase(i,1);
i--;
break;
case '@':
normal.erase(i,1);
i--;
break;
case '#':
normal.erase(i,1);
i--;
break;
case '%':
normal.erase(i,1);
i--;
break;
}
i++;
}
ofstream out;
out.open("History.txt");
out.clear();
for(int n = normal.length()-1; n > -1; n--)
{
out << normal[n];
}
out.close();
ifstream in;
in.open("History.txt");
in >> reverse;
in.close();
string whathappened;
if(normal == reverse)
{
whathappened = "This is a palindrome!";
cout << "\n" << whathappened;
}
else
{
whathappened = "Not a Palindrome!";
cout << "\n" << whathappened;
}
out.open("History.txt");
out.clear();
out << "Original: ";
out << normal_before_func;
out << "\nReverse: ";
out << reverse_before_func;
out << "\nResult: " << whathappened;
out.close();
cin.get();
return 0;
}
#include <iostream>
#include <string>
using namespace std;
bool isPalindrome(string input)
{
string cleanReversedWord = ""; //to declare a string with no undefined garbage to add letters only from input
for(int i = (input.length()-1) ; i >= 0 ; i--)// starts at end of input;
{
if( (int(input[i]) > 64 && int(input[i]) < 91) || (int(input[i]) > 96 && int(input[i]) < 123))
cleanReversedWord += input[i]; // adds only letters to cleanWord in reverse order
}
if(input == cleanReversedWord)
return true;
else
return false;
}
int main()
{
string input; // to hold the input word before symbols removed
cout<<"\n\tEnter a word to check for palimdrome: ";
getline(cin,input); //gets input
if(isPalindrome(input))
cout<<"\n\tThis word is a palindrome!"<<endl;
else
cout<<"\n\tThis word is not a palindrome!"<<endl;
getchar();
return 0;
}
#include <iostream>
#include <string>
using namespace std;
bool isPalindrome(string input)
{
string cleanReversedWord = ""; //to declare a string with no undefined garbage to add letters only from input
for(int i = (input.length()-1) ; i >= 0 ; i--)// starts at end of input;
{
if( (int(input[i]) > 64 && int(input[i]) < 91) || (int(input[i]) > 96 && int(input[i]) < 123))
cleanReversedWord += input[i]; // adds only letters to cleanWord in reverse order
}
if(input == cleanReversedWord)
return true;
else
return false;
}
int main()
{
string input; // to hold the input word before symbols removed
cout<<"\n\tEnter a word to check for palimdrome: ";
getline(cin,input); //gets input
if(isPalindrome(input))
cout<<"\n\tThis word is a palindrome!"<<endl;
else
cout<<"\n\tThis word is not a palindrome!"<<endl;
getchar();
return 0;
}
Copyright © 2026, NextGenUpdate.
All Rights Reserved.