.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> General >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to Write a Palindrome Programme using C# ?

Posted By:Syed Shakeer Hussain       Posted Date: April 11, 2009    Points: 10    Category: General    URL: http://www.dotnetspark.com  
 

How to Write a Palindrome Programme using C# ?

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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args) {
string str=string .Empty ;
Console.WriteLine("Enter a String");
string s = Console.ReadLine();
int i = s.Length;
//we can get the Length of string by using Length Property

for (int j=i -1; j >= 0; j--)
{
str = str + s[j ];
}
if (str == s)
{


Console.WriteLine(s + " is palindrome");


}
else
{
Console.WriteLine(s + " is not a palindeome"); }

Console.WriteLine(str);

Console.Read();

}
}
}


OutPut: Enter a String
madam
madam is palindrome
 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend