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

Explain the difference between c & c++?

579


What do you mean by inheritance in c++? Explain its types.

608


What is binary object model?

596


How can you say that a template is better than a base class?

580


What are signs of manipulation?

585






Specify some guidelines that should be followed while overloading operators?

616


What are smart pointers?

666


Is c better than c++?

611


Explain the use of this pointer?

634


Is c++ a good beginners programming language?

581


What parameter does the constructor to an ofstream object take?

607


What is the difference between cin.read() and cin.getline()?

553


Write about the retrieval of n number of objects during the process of delete[]p?

569


How does the copy constructor differ from the assignment operator (=)?

617


What is c++ coding?

651