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 string method in c#?
What does do in c#?
Is namespace a class?
What is difference between c and c sharp?
What does this keyword mean in c#?
What is hashtable c#?
Define satellite assembly in c#?
Which is better javascript or c#?
What is dependency in software?
What is the difference between c and c# programming?
What are the 2 broad classifications of fields in c#?
How does yield return work c#?
What are the different types of classes in c#?
Explain the difference between “system.array.clone()” and “system.array.copyto()” in c#?
Explain the difference between abstract class and interface.