TechieClues TechieClues
Updated date Mar 23, 2021
In this code snippet, we will see how to check whether the number is palindrome or Not using C#.
  • 1.7k
  • 0
  • 0

The Palindromes are numbers that read the same forward as backward. For example, 5885, 78587, 32823 and etc...

C# program to check a Number is Palindrome or Not:

using System;

namespace PalindromeCheck
{
    class Program
    {
        static void Main(string[] args)
        {
            // Declaration
            var sum = 0;
            // Get input parameter
            Console.Write("Enter the Number: ");
            var input = int.Parse(Console.ReadLine());
            // Assign the value to temp variable
            var temp = input;
            // Logic to check the number is Palindrome or not
            while (temp > 0)
            {
                var r = temp % 10;
                sum = (sum * 10) + r;
                temp = temp / 10;
            }
            if (input == sum)
                Console.Write("Number is Palindrome.");
            else
                Console.Write("Number is not Palindrome");
            Console.ReadKey();
        }
    }
}

Output:

Enter the Number: 5885
Number is Palindrome.
Enter the Number: 1235
Number is not Palindrome

ABOUT THE AUTHOR

TechieClues
TechieClues

I specialize in creating and sharing insightful content encompassing various programming languages and technologies. My expertise extends to Python, PHP, Java, ... For more detailed information, please check out the user profile

https://www.techieclues.com/profile/techieclues

Comments (0)

There are no comments. Be the first to comment!!!