Anonymous

How To Write A Program To Check Given String Is Palindrome Or Not?

2

2 Answers

Anonymous Profile
Anonymous answered
#include
#include
int stpal(char str[50]);
void main()
{
char str[50];
int pal;
clrscr();
printf(”\n\n\t ENTER A STRING…: “);
gets(str);
pal = stpal(str);
if(pal)
printf(”\n\t THE ENTERED STRING IS A PALINDROME”);
else
printf(”\n\t THE ENTERED STRING IS NOT A PALINDROME”);
getch();
}
int stpal(char str[50])
{
int I = 0, len = 0, pal = 1;
while(str[len]!=’\0')
len++;
len–;
for(I=0; I
Anonymous Profile
Anonymous answered
This code is written in c# (sharp)
using System;

namespace palindromecheck

{

    class Program

    {



        static void Main(string[] args)

        {

            string str, revstr;

         

            Console.WriteLine("ASHISH
Bolta Hai Enter Any String to Know It is Palindrome or not");

         
str = Console.ReadLine();



            char[] tempstr = str.ToCharArray();

            Array.Reverse(tempstr);

         
revstr = new string(tempstr);



          // bool caseignore= str.Equals(revstr,
StringComparison.OrdinalIgnoreCase);

         

            if(string.Compare(str,revstr,true)==0)

            //if (caseignore == true)

            {

             
Console.WriteLine("ASHISH Bolta Hai "+str + " Is a Palindrome");

            }

            else

            {

             
Console.WriteLine("ASHISH Bolta Hai " + str + " Is Not a Palindrome");

            }

           

            Console.Read();

        }



       

    }

}

Answer Question

Anonymous