Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions STL C++/PalindromePrograminC++
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <iostream>
#include <string>


using namespace std;


int main()
{
string str, temp;
int i = 0, j;

cout << "Enter a string to check for Palindrome: ";
cin >> str;

temp = str;

j = str.length() - 1;

//Reversing the temp string.

while (i < j)
{
swap(str[i], str[j]);
i++;
j--;
}

if (temp == str)
{
cout << "The string is a palindrome." << endl;
}
else
{
cout << "The string is not a palindrome." << endl;
}

return 0;
}