Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication4
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine(">>>> Checking if the number is Palindrome <<<<");
- Console.WriteLine(">>>>>> Enter a number: <<<<<<");
- int num, temp, sum = 0, rem, y, x;
- num = int.Parse(Console.ReadLine());
- temp = num;
- y = num;
- x = 0;
- while (y > 0)
- {
- y = y / 10;
- x++;
- }
- while (x > 0)
- {
- rem = num % 10;
- num = num / 10;
- sum = sum * 10 + rem;
- x--;
- }
- if (temp == sum)
- {
- Console.WriteLine("Number is Palindrome");
- }
- else
- {
- Console.WriteLine("Number is not a palindrome");
- }
- Console.ReadLine();
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment