write program for palindrome

Answer Posted / prashant gupta

//Using C# Language

using System;

class Palindrome
{
public void CalculatePalindrome()
{
//int number;
Console.Write("Enter the no to check its
Palindromic property : ");
int number = int.Parse(Console.ReadLine());

int temp = number;
int sum = 0;

while (number > 0)
{

Int32 remainder = number % 10;
number = number / 10;
sum = sum * 10 + remainder;
}

if (sum == temp)
{
Console.WriteLine("The no {0} is
palindrome.", sum);
}

else
{
Console.WriteLine("The no {0} is not a
palindrom no.", sum);
}
}

public static void Main()
{
Palindrome _palindrome = new Palindrome();
_palindrome.CalculatePalindrome();
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why should you learn c++?

783


How does list r; differs from list r();?

885


the first character in the variable name must be an a) special symbol b) number c) alphabet

820


What do you mean by vtable and vptr in c++?

806


Do you know the use of vtable?

846


Are strings mutable in c++?

884


What is const pointer and const reference?

808


why is c++ called oops? Explain

790


Explain the uses oof nested class?

861


Is c++ free?

794


What is the difference between global variables and static varables?

798


What is the main function c++?

812


What is auto used for in c++?

762


What is an object in c++?

814


What are the benefits of operator overloading?

883