Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Palindrome
- {
- class Class1
- {
- static void Main(string[] args)
- {
- while (true)
- {
- Console.WriteLine("Digit a word:");
- string word = Console.ReadLine();
- if (word == "exit")
- break;
- VerifyPalindrome(word);
- }
- }
- private static void VerifyPalindrome(string word)
- {
- bool compare = true;
- int i = 0;
- while (i < (word.Length / 2) - 1)
- {
- if (compare)
- {
- for (int j = word.Length - 1; j >= 0; j--)
- {
- if (word[i] == word[j])
- compare = true;
- else
- {
- compare = false;
- break;
- }
- i++;
- }
- }
- else
- break;
- }
- if (compare)
- Console.WriteLine("This is a Palindrome word");
- else
- Console.WriteLine("This is NOT a Palindrome word");
- }
- }
- }
Add Comment
Please, Sign In to add comment