Palindrome Number Program in C#


Prev Tutorial Next Tutorial

Palindrome Number Program in C#

To check number is palindrome or not first reverse number if resultant number is same like original number then it is palindrome number other wise nor palindrome.

Palindrome Number Program in C#

using System;

namespace Palindrome
{
class Program
{
static void Main(string[] args)
{
int num, rem, sum = 0, temp;
Console.Write("Enter any number: ");
num = Convert.ToInt32(Console.ReadLine());
temp = num;
while (num>0)
{
rem = num % 10;  //find remainder by dividing with 10
num = num / 10; //find quotient by dividing with 10
sum = sum * 10 + rem;
}
if (temp == sum)
{
Console.WriteLine("Number is Palindrome");
}
else
{
Console.WriteLine("Number is not a palindrome");
}
Console.ReadLine();
 }
}
}

Output

Enter any Number: 234
Number is not a palindrome

Output

Enter any Number: 231
Number is palindrome

Prev Tutorial Next Tutorial

Advertisements
Download Projects

Advertisements

Download WhatsApp Status Video

Buy This Ad Space Only $50 per Month, Ad Size 300X250 Contact on: [email protected] WhatsApp no. 8882538826