->Write a program a give the input and check the palindrome or not?
class Program
{ static void Main(string[] args)
{
int revers=0;
Console.WriteLine("Enter the number");
int n = Convert.ToInt32(Console.ReadLine());
int temp = n;
while (n > 0)
{
int reminder = n % 10;
revers = revers * 10 + reminder;
n = n / 10;
} Console.WriteLine(revers);
if(temp==revers)
{
Console.WriteLine("this is palindrome");
}
else
{
Console.WriteLine("this is not palindrome");
} Console.WriteLine();
Console.ReadLine();
}
}
OUTPUT:
Enter the number: 121
This is palindrome
Enter the number:121
This is not palindrome
No comments:
Post a Comment