Introduction:
Palindrome means if you reverse the sting or no the resulting string or no is same as original string or no. For example take a string 'madam'. If you reverse this word the resulting word is same as original word
Code:-
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
PalindromeOfString
{
class
Program
{
static void Main(string[] args)
{
Console.WriteLine("Check
the entered string or no is palindrome or not.");
Console.Write("Enter
the string or no:");
string str = Console.ReadLine();
string s = string.Empty;
int i = str.Length;
for (int j = i - 1; j
>= 0;j-- )
{
s = s + str[j];
}
if (s == str)
{
Console.WriteLine("the
given string or no is palindrome.");
}
else
{
Console.WriteLine("The
given no or string not a palindrome.");
}
Console.ReadKey();
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.