A palindrome is a string such that if you reverse it, it will not change. The string should be remain same and meaning also remain same.
Mom, Malayalam, Wow, Deleveled, etc.
static bool IsPalindrome(string src) { bool palindrome = true; for (int i = 0; i < src.Length / 2 + 1; i++) { if (src[i] != src[src.Length - i - 1]) { palindrome = false; break; } } return palindrome; } static void Main(string[] args) { Console.Write("ENTER A STRING :- "); string s = Console.ReadLine(); if (IsPalindrome(s) == true) { Console.WriteLine(s + " IS A PALINDROME"); } else { Console.WriteLine(s + " IS NOT A PALINDROME"); } }
ENTER A STRING :- MOM MOM IS A PALINDROME.