code to check if palindromic number ort not (c#)
in main
static void Main(string[] args)
{
Console.WriteLine("Give me a number");
int a = int.Parse(Console.ReadLine());
palidrom(a);
}
in method
static void palidrom(int a)
{
int sum = 0;
int b;
int number = a;
while (a>0)
{
b = a % 10;
sum = (sum*10) + b;
a = a / 10;
}
if (number == sum)
{
Console.WriteLine("it's polidromic");
}
else
{
Console.WriteLine("it's not polidromic");
}
}
Comments
Post a Comment