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
How much do c++ programmers make?
What is extern c++?
Search for: what is pair in c++?
What is encapsulation in C++? Give an example.
How do you traverse a btree in backward in-order?
Evaluate as true or false: !(1 &&0 || !1) a) True b) False c) Invalid statement
What do you mean by early binding?
What methods can be overridden in java?
Why do we need c++?
Is sorted c++?
Explain selection sorting?
Will a recursive function without an end condition every quit, in practice a) Compiler-Specific (Some can convert to an infinite loop) b) No c) Yes
What is stoi in c++?
What information can an exception contain?
What is a pointer with example?