Palindrome Number Program in C#
Advertisements
Palindrome Number Program in C#
To check number is palindrome or not first reverse number if resultant number is same like original number then it is palindrome number other wise nor palindrome.
Palindrome Number Program in C#
using System; namespace Palindrome { class Program { static void Main(string[] args) { int num, rem, sum = 0, temp; Console.Write("Enter any number: "); num = Convert.ToInt32(Console.ReadLine()); temp = num; while (num>0) { rem = num % 10; //find remainder by dividing with 10 num = num / 10; //find quotient by dividing with 10 sum = sum * 10 + rem; } if (temp == sum) { Console.WriteLine("Number is Palindrome"); } else { Console.WriteLine("Number is not a palindrome"); } Console.ReadLine(); } } }
Output
Enter any Number: 234 Number is not a palindrome
Output
Enter any Number: 231 Number is palindrome
Google Advertisment