Palindrome program in C#

In this post, we will learn about Palindrome program in C# with an example.

Palindrome program in C#

Palindrome program in C#


In my previous posts I have explained various topics like Prime Number in C#.Net, Multi Dimensional array in C#, Arrays In C#, Fill DropDownList from JSON Array using jQuery, Anonymous Types In C# ,Sealed Class in C#, Continue keyword in C#.Net, Difference between string and StringBuilder in C#, Difference between a struct and a class in C#

Now in this post, I will explain Palindrome program in C# with appropriate example. A palindrome number is a number that is same after reverse of it. For example 121, 38583, 303, 121, 48984, are the palindrome numbers.

Palindrome number steps:

  • Get(Read) the number from user
  • Store the number in temporary variable
  • Reverse the number
  • Compare the temporary number with reversed number
  • If both the numbers are same, print the message palindrome number
  • Else print the message not palindrome number

Now create Console Application in Visual Studio and write below lines of code in it.

using System;

namespace DotNetK
    class Program
        static void Main(string[] args)
            // Program to check whether the given number is paligdrom or not

            int number, r, sum = 0, temp;
            Console.Write("Enter the Number to check Palindrome: ");
            number = int.Parse(Console.ReadLine());
            temp = number;
            while (number > 0)
                r = number % 10;
                sum = (sum * 10) + r;
                number = number / 10;
            if (temp == sum)
                Console.Write("Number is Palindrome.");
                Console.Write("Number is not Palindrome");     

            Console.ReadKey(); // To hold the console screen.


Read :


You can also read about ASP.NET,C#.NET, JQUERY, AJAX.
I hope you get an idea about Palindrome program in C#.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you liked this post, don’t forget to share this.

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *