Write a C# Program to check a number is Palindrome or not.

Write a C# Program to check a number is Palindrome or not. give an example?.

Last updated:11/22/2021 10:40:18 PM

1 Answers

Ashutosh Kumar Verma
Ashutosh Kumar Verma

Palindrome Number:

A Palindrome number is a number which are same as its reverse order means if we reverse a number and no any changes in sequence of that number as its original sequence then it called as a palindrome number.

In other word, it has same reads in sequence of forward and backward.

Ex- 	12321, 45654, 11211 etc. 

Program:

using System;

public class Program
{
 public static void Main()
 {
  int number;
  Console.WriteLine('Enter a number to check whether is Palindrome or not');
  number= int.Parse(Console.ReadLine());
  int num=number;
  int i,result=0,rem;
  while(num!=0)
  {
   rem=num%10;
   result=result*10+rem;
   num=num/10;
  }
  if(number==result)
  {
  Console.WriteLine(number+' is a Palindrome number');
  }else
  {
  Console.WriteLine(number+' is not a Palindrome number ');
  }
 }
}

Output:

Enter a number to check whether is Palindrome  or not

12321
12321 is a Palindrome number
Enter a number to check whether is Palindrome  or not

789654
789654 is not a Palindrome number


Answer