Answer Posted / dadi
static void checkPalindrome()
{
Console.WriteLine("please enter a string");
string str = Console.ReadLine();
bool isPalindrome = true;
int count = str.Length;
for (int i = 0; i < count / 2; i++)
{
if (str[i] != str[count - i - 1])
{//check char[0]==char[n-1], char[1]== char[n-2] and so on......
isPalindrome = false;
break;
}
}
Console.WriteLine("entered string {0} is {1} palindrome", str, (isPalindrome) ? "a" : "not a");
Console.Read();
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
What is the benefit of using interface in c#?
What is msil in c#?
What does namespace mean?
Explain namespaces in c#.
What is use of list in c#?
What does m mean in decimal c#?
What is parsing? How to parse a date time string?
What Is A Satellite Assembly?
What is c# and why it is used for?
Differentiate between method overriding from method overloading with its functionality?
What is the difference between method overriding and method overloading?
Is php easier than c#?
Will the following code compile and run?
What are constructors in c#?
What is iqueryable in linq?