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 language is arduino?
what happens if you inherit multiple interfaces and they have conflicting method names?
Explain about WSDL
How to implement singleton design pattern in c#?
What is arraylist c#?
How do I stop my console from closing in c#?
Is array ienumerable c#?
What is Wrapper class in dot net?
Is stringbuilder better than string?
How will you allow a class to be inherited, but prevent the method from being over-ridden?
Why should I use interface in c#?
Define assert() method? How does it work?
What is the use of static in c#?
Are all methods virtual in c#?
Why c# is called c sharp?