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
Explain the difference between c & c++?
What do you mean by inheritance in c++? Explain its types.
What is binary object model?
How can you say that a template is better than a base class?
What are signs of manipulation?
Specify some guidelines that should be followed while overloading operators?
What are smart pointers?
Is c better than c++?
Explain the use of this pointer?
Is c++ a good beginners programming language?
What parameter does the constructor to an ofstream object take?
What is the difference between cin.read() and cin.getline()?
Write about the retrieval of n number of objects during the process of delete[]p?
How does the copy constructor differ from the assignment operator (=)?
What is c++ coding?