Palindrome String Program in C#


Prev Tutorial Next Tutorial

Palindrome String Program in C#

To check string is palindrome or not first reverse string if resultant string is same like original string then it is palindrome string other wise nor palindrome.

Palindrome String Program in C#

using System;

namespace palindrome
{
class Program
{
static void Main(string[] args)
{
string s,revs="";
Console.WriteLine(" Enter string");
s = Console.ReadLine();
for (int i=s.Length-1; i>=0; i--) //String Reverse
 {
 revs += s[i].ToString();
 }
 if (revs == s)
 {
 Console.WriteLine("String is Palindrome");
 }
 else
 {
 Console.WriteLine("String is not Palindrome");
 }
 Console.ReadKey();
 }
 }
}

Output

Enter any String: Hello
String is not a palindrome

Output

Enter any String: Mam
String is palindrome

Prev Tutorial Next Tutorial

Google Advertisements
Download Projects

Google Adsense Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 300X250 Contact on: hitesh.xc@gmail.com WhatsApp no. 8882538826

Yahoo Advertisements