C++ Program to Check Palindrome String
Here, you will learn and get the example code of C++ Program to Check Palindrome String.
Palindrome string is a string of characters (letters, numbers, punctuation) that reads the same forwards and backwards.
For example:-
“madam” is a palindrome string, as it reads the same both forward and backward.
Program code to Check Palindrome String
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include<iostream> #include<string.h> using namespace std; int main() { char a[100], b[100]; cout<<"\n\n\t*** String Palindrome Program in C ***\n"; cout<<"\n\n\tEnter the string to check palindrome :"; gets(a); strcpy(b, a); // Copying the input string strrev(b); // Reversing the string // Comparing input string with the reverse string if (strcmp(a, b) == 0) cout<<"\n\tThe string is palindrome."; else cout<<"\n\tThe string isn't palindrome."; return 0; } |
Output
Check out our other C++ programming Examples