palindrome programe how can print palindrome write programe for palindrome user input to show palindrome programe input string show palindrome

Ubaid
Posted by Ubaid under C# category on | Points: 40 | Views : 2162
Note: Create new Console application from dotnet or simple write the following text in note paid then execute..
any way ...

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

namespace palindromeExample //(this will be your project name like create new application and write the name)
{
public class Program
{
public void Palindrome(string input) //(this is a method name)
{
string getInput = input; //(take input from user )
int length = getInput.Length;
string strCmp = "";
for (int j = length-1; j>=0; j--)
{
strCmp = strCmp + getInput[j]; //(get one by one user input and reverse)
}
if (strCmp == getInput) //(check condition is palindrome or not)
{
Console.WriteLine("this is palinderome");
}
else
{
Console.WriteLine("not vlaid palindrome....");
}
Console.WriteLine(strCmp);
}
static void Main(string[] args)
{
string UsrInput = "";
Console.WriteLine("Enter the input value:\n");
UsrInput = Console.ReadLine();
if (UsrInput != "")
{
Program objPrg = new Program();
objPrg.Palindrome(UsrInput);
}
else
{
Console.WriteLine("enter value...");
}
Console.Read(); // using this line screen will not disappear..

}



}
}

Comments or Responses

Posted by: T.Saravanan on: 4/25/2012 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi,

Kindly post your code inside the code tag.

Login to post response