Thursday, 24 January 2013

Palindrom

// palidrom.cpp : Defines the entry point for the console application.
//



#include <iostream>
#include <conio.h>
#include <string.h>
using namespace std;
int main()
{

 char strn[80];
int i,j,flag=0,len;
cout<<"Enter the string:";
cin.getline(strn,80);

len=strlen(strn);
cout << endl << len;
for(i=0,j=len-1;i<=(len/2);++i,--j)
{
    cout << i <<"=i" << endl << " " << j << "= j" << endl;

if(strn[i]==strn[j])
flag=1;
else if (strn[i]!=strn[j])
{
    flag=0;
break;
}

}

if(flag)
cout<<"Palindrome";

else cout<<"Not a palindrome";

getch();
}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Enterprise Project Management