C++ program to check whether a given string is a palindrome
kw.cpp
#include<iostream>
#include<bits/stdc++.h>usingnamespacestd;intmain(){cout<<"———————————————————————————————————————————";cout<<"\nProgram to check string is palindrome | not";cout<<"\n———————————————————————————————————————————";strings1,s2;cout<<"\nEnter the string ";getline(cin,s1);s2=s1;reverse(s1.begin(),s1.end());if(s1==s2){cout<<"\n"<<s2<<" is a palindrome";}else{cout<<"\n"<<s2<<" is not a palindrome";}cout<<"\n———————————————————————————————————————————\n";}
Output
kodingwindow@kw:~$ g++ kw.cpp kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to check string is palindrome | not
———————————————————————————————————————————
Enter the string WAR
WAR is not a palindrome
———————————————————————————————————————————
kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to check string is palindrome | not
———————————————————————————————————————————
Enter the string RAR
RAR is a palindrome
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.