Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace IsPalindrome
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter your number :");
- int x = int.Parse(Console.ReadLine());
- Console.WriteLine(IsPalindrome(x));
- Console.ReadKey();
- }
- static bool IsPalindrome(int x)
- {
- if (x <= 0 || (x % 10 == 0 && x != 0))
- return false;
- int reverse = 0;
- while (x > reverse)
- {
- reverse = reverse * 10 + x % 10;
- x /= 10;
- }
- return x == reverse || x == reverse / 10;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement