Palindrome String Program in C#

Advertisements

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 Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements