Check Palindrome Number in C#

Hi Programmers, Here is the article to check palindrome numbers in should use any loop such as while,for ,do while etc to solve the program.
Palindrome Number is a number that remains the same when its digits are reversed.Let’s see the program

Code Explanation :-
if you debug the program then control first comes to Main() method “static void Main(string[] args)” Now it starts processing Main Method block.
Inside Main Method i have taken four integers variables int n, rem, rev = 0, temp; here rev initialize with zero.
Console.Write Method is used display contents on the output screen.Console.Write(“Enter Any Positive Number : “);
n = int.Parse(Console.ReadLine()); Console.ReadLine() is used to read values in string and after applying int.Parse method,
that converts string value into integer.
temp = n; here n value go to temp.

while(n > 0) if n > 0 then while loop continue.
rem = n % 10; n % 10 value go to rem here , modulous operator returns remainder.
rev = rev * 10 + rem; rev value multiply with 10 and add the value with rem.
n = n / 10; n / 10 , division operator return value of quotent.
if while loop condition false then control move to
Console.WriteLine(“Entered Number is ” + temp); “Entered Number is ” that display into output screen with temp value.
if(temp == rev) supoose temp and rev value is equal then output display Number is Palindrome else Not a Palindrome Number.

Happy Coding … Thanks.

Post Author: adama