//Using C++
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();
char *wrd;
int n=0;
cout<<"Enter a string:";
cin>>wrd;
while(wrd[n]!='\0')
n++; //Counting length of the string
n--;
for(int i=0;i<n/2;i++,n--)
{
if(wrd[i]!=wrd[n])
{
cout<<"\nNot Palindrome!";
getch();
exit(0);
}
}
cout<<"\nPalindrome.";
getch();
}
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();
char *wrd;
int n=0;
cout<<"Enter a string:";
cin>>wrd;
while(wrd[n]!='\0')
n++; //Counting length of the string
n--;
for(int i=0;i<n/2;i++,n--)
{
if(wrd[i]!=wrd[n])
{
cout<<"\nNot Palindrome!";
getch();
exit(0);
}
}
cout<<"\nPalindrome.";
getch();
}
No comments:
Post a Comment