TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ravi Yadav
NA
307
245.8k
Write a program to check any number or string is palindrome
Aug 26 2016 4:01 AM
class
Ravishanakr
{
static
void
Main(string[] args)
{
Ravishanakr _Ravi = new Ravishanakr();
Console.WriteLine("Enter string by keyboard");
string _OldString = Console.ReadLine();
_Ravi._PlandromString(_OldString);
Console.WriteLine("Enter number by keyboard");
long _Number = Convert.ToInt64(Console.ReadLine());
_Ravi._PlandromNumber(_Number);
Console.ReadLine();
}
private void _PlandromString(string _OldString)
{
string _NewString = string.Empty;
try
{
for (int i = _OldString.Length - 1; i >= 0; i--)
{
_NewString += _OldString[i];
}
if (_OldString.Equals(_NewString))
Console.WriteLine("String is palindrome");
else
Console.WriteLine("String is not palindrome");
}
catch (Exception Ex)
{
Ex.Message.ToString();
}
}
private void _PlandromNumber(long _Number)
{
long _OldNumber, _Reverse = 0, _Reminder;
_OldNumber = _Number;
try
{
while (_Number != 0)
{
_Reminder = _Number % 10;
_Reverse = _Reverse * 10 + _Reminder;
_Number /= 10;
}
if (_OldNumber == _Reverse)
Console.WriteLine("Number is palindrome");
else
Console.WriteLine("Number is not palindrome");
}
catch (Exception EX)
{
EX.Message.ToString();
}
}
}
Output:
Reply
Answers (
2
)
create login page with azure in asp.net
how to pass mutiple city id for each loop