Write a program to find the Palindrome or not ? in c++

 Write a program to find the Palindrome or not ? in c++  


#include<bits/stdc++.h>

using namespace std;



int main(){

    string s;

    cout<<"Enter the string "<<endl;

    cin>>s;

    string tmp=s;

    int i=0,  j=s.size()-1;

    while(i<=j){

        swap(tmp[i++], tmp[j--]);

    }

    

    if(s==tmp){

        cout<<"The string is Palindrome "<<s<<endl;

    }

    else{

        cout<<"The string is not Palindrome "<<s<<endl;

    }

    return 0;

}


Output is:

Enter the string 

moom

The string is Palindrome moom







Post a Comment

0 Comments