Write a ‘C’ program to check whether given string is palindrome or not

#include<stdio.h>
#include<conio.h>
#include<string.h>
# define SIZE 26
void main()
{
char s[SIZE];
int flag=0,i,j,l;
clrscr();
printf("\n enter the string\n\t");
gets(s);
l=strlen(s);
for
(i=0,j=l-1;s[i]!='\0';i++,j--)
{
if(s[i]!=s[j])
{
flag=1;
break;
}
}
if(flag==0)
printf("\n given string is palindrom");
else
printf("\n given string is not palindrom");
getch();
}

7 comments:

  1. thanks for posting this program it is awesome

    ReplyDelete
  2. #include
    #include
    #include
    # define SIZE 26
    void main()
    {
    char s[SIZE];
    int flag=0,i,j,l;
    clrscr();
    printf("\n enter the string\n\t");
    gets(s);
    l=strlen(s);
    for
    (i=0,j=l-1;s[i]!='\0';i++,j--)
    {
    if(s[i]!=s[j])
    {
    flag=1;
    break;
    }
    }
    if(flag==0)
    printf("\n given string is palindrom");
    else
    printf("\n given string is not palindrom");
    getch();
    }

    ReplyDelete
  3. can u plz tel me use of flag in this :/

    ReplyDelete
    Replies
    1. write a program the read a message an chack wherther it is a palindrome (the a letters in massege are the same for left and right as form to right and left )

      enter a message : he live as a delivel , eh?
      enter a message : manad i am adam
      not a palindrom

      Delete
  4. write a program the read a message an chack wherther it is a palindrome (the a letters in massege are the same for left and right as form to right and left )

    enter a message : he live as a delivel , eh?

    enter a message : manad i am adam

    not a palindrom

    ReplyDelete
    Replies
    1. write a program the read a message an chack wherther it is a palindrome (the a letters in massege are the same for left and right as form to right and left )

      enter a message : he live as a delivel , eh?

      Enter a message : manad i am adam

      not a palindrom

      Delete
    2. write a program the read a message an chack wherther it is a palindrome (the a letters in massege are the same for left and right as form to right and left )

      enter a message : he live as a delivel , eh?

      enter a message : manad i am adam

      not a palindrom

      Delete