Palindrom Number in C#
Defination: The number is called palindrom if in three digit number first number and last number are same then it is called palindrom number. there are some example given as below.
For example : 121, 232,222,323,434,111 etc... are example of palindrom number...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num, sum = 0, temp, i;
Console.WriteLine("enter the number:");
num = Convert.ToInt32(Console.ReadLine());
temp = num;
while (num != 0)
{
i = num % 10;
sum = sum *10+ i ;
num = num / 10;
}
if (temp == sum)
Console.WriteLine("palindrom", sum);
else
{
Console.WriteLine("not palindrom", sum);
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num, sum = 0, temp, i;
Console.WriteLine("enter the number:");
num = Convert.ToInt32(Console.ReadLine());
temp = num;
while (num != 0)
{
i = num % 10;
sum = sum *10+ i ;
num = num / 10;
}
if (temp == sum)
Console.WriteLine("palindrom", sum);
else
{
Console.WriteLine("not palindrom", sum);
}
}
}
}
Sign up here with your email
ConversionConversion EmoticonEmoticon