Asp . Net || SQL Server
Friday, 23 January 2015
C # Program to check whether a given number is a palindrome.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Palindrome_Number_check
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter a Number Series To check :");
int num, temp, reminder, reverse = 0;
num = int.Parse(Console.ReadLine());
temp = num;
while(num > 0)
{
reminder = num % 10;
reverse = reverse * 10 + reminder;
num = num / 10;
}
if (temp == reverse)
{
Console.WriteLine("");
Console.WriteLine("Entered Number is {0}", temp);
Console.WriteLine("It is a Palindrome");
}
else
{
Console.WriteLine("The entered number is not a palindrome");
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment