C#: Check whether a number is a palindrome or not
C# Sharp For Loop: Exercise-38 with Solution
Write a program in C# Sharp to check whether a number is a palindrome or not.
Pictorial Presentation:

Sample Solution:
C# Sharp Code:
using System;
public class Exercise38
{
public static void Main()
{
int num,r,sum=0,t;
Console.Write("\n\n");
Console.Write("Check whether a number is a palindrome or not:\n");
Console.Write("------------------------------------------------");
Console.Write("\n\n");
Console.Write("Input a number: ");
num = Convert.ToInt32(Console.ReadLine());
for(t=num;num!=0;num=num/10){
r=num % 10;
sum=sum*10+r;
}
if(t==sum)
Console.Write("{0} is a palindrome number.\n",t);
else
Console.Write("{0} is not a palindrome number.\n",t);
}
}
Sample Output:
Check whether a number is a palindrome or not: ------------------------------------------------ Input a number: 8 8 is a palindrome number.
Flowchart:

C# Sharp Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a program in C# Sharp to display the number in reverse order.
Next: Write a program in C# Sharp to find the number and sum of all integer between 100 and 200 which are divisible by 9.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join