Created
July 15, 2022 03:11
-
-
Save bharathmuddada/639afb26b4f1c733657e9014ca4f07fb to your computer and use it in GitHub Desktop.
Check whether given string is palindrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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