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
Are structs value types or reference types?
Can partial class be inherited?
What is stringreader in c#?
How do you specify a custom attribute for the entire assembly (rather than for a class)?
What do you mean by streamreader/streamwriter class in c#?
What's the difference between an integer and int?
What is the different types of private assembly and shared assembly?
Describe the types of comments in c#?
Can constructor have return type c#?
What is delegation in oops?
What is difference between hashtable and dictionary in c#?
What is yield c#?
What is the use of table aliases?
What is console writeline in c#?
What's new in c#?