/*Write a C program to determine if the given string is a palindrome or not
*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char a[35];
int j,i,sl,flag=0;
printf("\n This program checks the validity of a string as a palindrome");
printf("\n Enter the String to verify ");
gets(a);
sl=strlen(a);
for(i=0,j=sl-1;i!=j;i++,j--)
{
if(a[i]!=a[j])
{
printf("\n The given string is not a palindrome");
flag=1;
break;
}
}
if(flag==0)
{
printf("\n the given string is a palindrome");
}
}
*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char a[35];
int j,i,sl,flag=0;
printf("\n This program checks the validity of a string as a palindrome");
printf("\n Enter the String to verify ");
gets(a);
sl=strlen(a);
for(i=0,j=sl-1;i!=j;i++,j--)
{
if(a[i]!=a[j])
{
printf("\n The given string is not a palindrome");
flag=1;
break;
}
}
if(flag==0)
{
printf("\n the given string is a palindrome");
}
}
No comments:
Post a Comment