Palindrome Number Program in C#

Advertisements

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

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements