/*Program to find the given string is a Palindrome or not */
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[15];
int i, len, count=0;
clrscr();
printf("\nEnter a string: ");
scanf("%s", a);
len=strlen(a);
for(i=0; i<len; i++)
{
if(a[i]==a[len-i-1])
count=count+1;
}
if(count==len)
{
printf("\nThe given string is a Palindrome");
}
else
{
printf("\nThe given string is not a Palindrome");
}
getch();
}
OUTPUT:
Enter a string: hannah
The given string is a Palindrome
Enter a string: welcome
The given string is not a Palindrome
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[15];
int i, len, count=0;
clrscr();
printf("\nEnter a string: ");
scanf("%s", a);
len=strlen(a);
for(i=0; i<len; i++)
{
if(a[i]==a[len-i-1])
count=count+1;
}
if(count==len)
{
printf("\nThe given string is a Palindrome");
}
else
{
printf("\nThe given string is not a Palindrome");
}
getch();
}
OUTPUT:
Enter a string: hannah
The given string is a Palindrome
Enter a string: welcome
The given string is not a Palindrome
Comments
Post a Comment