Palindrome string program in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication78
{
class Program
{
static void Main(string[] args)
{
string Str, Revstr = "";
int i;
Console.Write("Enter A String : ");
Str = Console.ReadLine();
for (i = Str.Length - 1; i >= 0; i--)
{
Revstr = Revstr + Str[i];
}
if (Revstr == Str)
{
Console.WriteLine("entered String Is palindrome");
Console.ReadLine();
}
else
{
Console.WriteLine("entered String Is not palindrome ");
Console.ReadLine();
}
}
}
}
Output screenshot:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication78
{
class Program
{
static void Main(string[] args)
{
string Str, Revstr = "";
int i;
Console.Write("Enter A String : ");
Str = Console.ReadLine();
for (i = Str.Length - 1; i >= 0; i--)
{
Revstr = Revstr + Str[i];
}
if (Revstr == Str)
{
Console.WriteLine("entered String Is palindrome");
Console.ReadLine();
}
else
{
Console.WriteLine("entered String Is not palindrome ");
Console.ReadLine();
}
}
}
}
Output screenshot:
Thanks brother
ReplyDelete