Q:

C# program to check whether a given number is Palindrome or not

belongs to collection: C# Basic Programs | Looping programs

0

C# program to check whether a given number is Palindrome or not

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Consider the program:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    
    class Program
    {
        static void Main(string[] args)
        {
            int     number    = 0;
            int     tNumber   = 0;
            int     rem       = 0;
            int     rev       = 0;
            

            Console.Write("Enter Number : ");
            tNumber = number = int.Parse(Console.ReadLine());

            //To find out total number of digits in number
            while (number > 0)
            {
                rem = number %10;
                rev = rev * 10 + rem;
                number = number / 10;
                
            }

            
            if (rev == tNumber)
                Console.WriteLine("Given Number is Palindrome");
            else
                Console.WriteLine("Given Number is not a Palindrome");
        }
    }
}

Output

Enter Number : 12321
Given Number is Palindrome

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Define Fibonacci series - Write a program to print... >>
<< Define Armstrong numbers and write program to chec...