Skip to content

Instantly share code, notes, and snippets.

@bharathmuddada
Created July 15, 2022 03:11
Show Gist options
  • Save bharathmuddada/639afb26b4f1c733657e9014ca4f07fb to your computer and use it in GitHub Desktop.
Save bharathmuddada/639afb26b4f1c733657e9014ca4f07fb to your computer and use it in GitHub Desktop.
Check whether given string is palindrome
public class PalindromeCheck
{
public static void Main(String[] args)
{
// Palindrome -- Level
//1. Reverse string.
//2. Compare the reversedstring with actual string.
string actualString = "level";
string reverseString = "";
for (int i = actualString.Length - 1; i >= 0; i--) {
reverseString += actualString[i];
}
if(reverseString == actualString)
Console.WriteLine($"{actualString} is a palindrome :{reverseString}");
else
Console.WriteLine($"{actualString} is not a palindrome :{reverseString}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment