1.

Write a program in C# Sharp to find if a given string is palindrome or not?

Answer» INTERNAL static void chkPalindrome(string str) { bool flag = FALSE; for (INT i = 0, j = str.Length - 1; i < str.Length / 2; i++, j--) { if (str[i] != str[j]) { flag = false; break; } ELSE flag = true; } if (flag) { Console.WriteLine("Palindrome"); } else Console.WriteLine("Not Palindrome");

Output: 

Input: Key Output: Not Palindrome
Input: step on no pets Output: Palindrome 



Discussion

No Comment Found