Friday, 13 December 2013

C++ PROGRAM TO CHECK WHETHER THE INPUTTED WORD IS PALINDROME OR NOT WITHOUT USING ANY BUILT IN FUNCTION

//Program to check for palindrome


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

char x[100],y[100];
int temp1,temp2=0,j;

cout << "Enter Name/Digits :";
cin >> x;
temp1 = strlen(x)-1;
for(j= 0;j<strlen(x);j++)
y[j] = x[temp1 - j];
y[j] = '\0';
x[j] = '\0';
for(int k =0; k<strlen(x); k++)
{
    if (x[k]==y[k])
     temp2 = temp2 + 1;
}
if (strlen(x) == temp2)
 cout<<"Palindrome";
else
  cout<<"Not a palindrome";
getch();
}


OUTPUT



No comments:

Post a Comment