/*
program to check whether a string is palindrome or not in c++
*/
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
int i,j,k,flag=0;
char a[80];
cout<<"Enter the string:";
gets(a);
k=strlen(a);
for(i=0,j=k-1;i<=j;i++,j--)
{
if(a[i]!=a[j])
{
flag=1;
break;
}
}
if(flag>0)
cout<<"String is not palindrome.";
else
cout<<"String is palindrome.";
getch();
}
0 comments:
Post a Comment