# C# - Palindrome Number Program

Given a number, we have to check whether it is a Palindrome or not using C# program?
[Last updated : March 19, 2023]

To understand the program of palindrome number, first we should understand the concept of palindrome number.

## What are Palindrome Number?

Palindrome numbers are those numbers that are equal to its reverse.

For example:

• 121 is palindrome number.
• 112 is not a palindrome number.
• 12321 is a palindrome number.
• 12345 is not a palindrome number.

In this program, we will read an integer number and check whether it is Palindrome or not. To check palindrome, we will find its reverse number and then compare if reverse of a number if equal to its value (actual number) or not, if reverse and numbers are same then given number will be palindrome.

## C# program to check whether a given number is Palindrome or not

```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{

class Program
{
static void Main(string[] args)
{
int     number    = 0;
int     tNumber   = 0;
int     rem       = 0;
int     rev       = 0;

Console.Write("Enter Number : ");

//To find out total number of digits in number
while (number > 0)
{
rem = number %10;
rev = rev * 10 + rem;
number = number / 10;

}

if (rev == tNumber)
Console.WriteLine("Given Number is Palindrome");
else
Console.WriteLine("Given Number is not a Palindrome");
}
}
}
```

## Output

```Enter Number : 12321
Given Number is Palindrome
```

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates