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();
}
#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();
}
thanks for posting this program it is awesome
ReplyDelete#include
ReplyDelete#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();
}
can u plz tel me use of flag in this :/
ReplyDeletewrite 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 )
Deleteenter a message : he live as a delivel , eh?
enter a message : manad i am adam
not a palindrom
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 )
ReplyDeleteenter a message : he live as a delivel , eh?
enter a message : manad i am adam
not a palindrom
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 )
Deleteenter a message : he live as a delivel , eh?
Enter a message : manad i am adam
not a palindrom
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 )
Deleteenter a message : he live as a delivel , eh?
enter a message : manad i am adam
not a palindrom