Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StringPalindrome
{
class Program
{
static void Main(string[] args)
{
String str = String.Empty;
Console.WriteLine("Enter any word to check Palindrome");
String s = "";
s = Console.ReadLine();
int i = s.Length;
for (int j=i-1;j>=0; j--)
{
str=str+s[j];
}
if (str == s)
{
Console.WriteLine("\n"+""+ s+" "+"String is palindrome");
}
else
Console.WriteLine("\n"+""+s+" "+"String is not palindrome");
Console.ReadKey();
}
}
}
Output:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StringPalindrome
{
class Program
{
static void Main(string[] args)
{
String str = String.Empty;
Console.WriteLine("Enter any word to check Palindrome");
String s = "";
s = Console.ReadLine();
int i = s.Length;
for (int j=i-1;j>=0; j--)
{
str=str+s[j];
}
if (str == s)
{
Console.WriteLine("\n"+""+ s+" "+"String is palindrome");
}
else
Console.WriteLine("\n"+""+s+" "+"String is not palindrome");
Console.ReadKey();
}
}
}
Output:
No comments:
Post a Comment