C++ Interview

C/C++ Program to Check if a Given String is Palindrome

The most asked questions in TCS/ Wipro/Infosys and other MNC.                                              Palindrome:  A string is called palindrome if its reverse of the string is the same as the original string. For Example: "GEEG", "LOOL","AABBBAA".

Palindrome:  A string is called palindrome if its reverse of the string is the same as the original string. For Example: “GEEG”, “LOOL”,”AABBBAA”.

The most asked questions in TCS/ Wipro/Infosys and other MNC.

Program in C/C++ to check the string is Palindrome or Not.

#include <iostream>
#include <string>

using namespace std;

int main ()
{
    string st;
    cout<<"Enter String ";
    cin>>st;
    
    int i=0;
    int l=st.size()-1;
    while(l>i)
    {
        if(st[i++]!=st[l--])
        {
            cout<<"It is not Pallindrome";
            return 0;
        }
        
    }
    cout<<"It is Pallindrome";
    

return 0;
}
Input:geeg
Output:It is Pallindrome

Input:aabbb
Output:It is not Pallindrome

Compile Program Here 

Most Asked Question in Interview.

Leave a Reply

%d bloggers like this: