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
Can the operator == be overloaded for comparing two arrays consisting of characters by using string comparison?
What is the difference between global int and static int declaration?
Explain the term memory alignment?
Write about the access privileges in c++ and also mention about its default access level?
How do you write a function that can reverse a linked-list?
Describe delete operator?
Why should you learn c++?
How would you find out if a linked-list is a cycle or not?
Define Virtual function in C++.
Which software is used to run c++ program?
What is enum class in c++?
What is the use of class in c++?
What are the advantages of inheritance in c++?
Carry out conversion of one object of user-defined type to another?
What is nested class in c++?