Write code for palindrome?

Answer Posted / manindra agrawal

using System;
using System.Collections.Generic;
using System.Text;


class plaindrome
{
public static void Main()
{

string str1="";
int n,i=0;
int status=0;
System.Console.WriteLine("Enter the value...");

str1=Console.ReadLine(); // accept the value from the user
int len;
len=str1.Length; //calculating Lenght of the string
n=len;
while(i<n/2)
{

if(str1[i]==str1[n-1])
{
status=1;
i++;
n--;
}

else
status=0;
break;
}

if(status==1)
System.Console.WriteLine("Given string is plaindrom");

else
System.Console.WriteLine("Given String is not Plaindrome");
}

}

Is This Answer Correct ?    7 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is ioc containers c#?

647


What is a scope in c#?

646


So let's say I have an application that uses myapp.dll assembly, version 1.0.0.0. There is a security bug in that assembly, and I publish the patch, issuing it under name myapp.dll 1.1.0.0. How do I tell the client applications that are already installed to start using this new myapp.dll?

668


How do you escape a character?

674


Can a string be null c#?

652


What is difference between array and list in c#?

618


Name which controls do not have events?

772


How many types of constructor are there in c#?

646


What are abstract classes in c#?

665


What is a service layer c#?

627


Is post back in c#?

705


How long has c# been around?

724


Why do we use namespace in c#?

696


What is xaml in c#?

697


what is IDisposal interface

900