WAP TO CHECK IF A STRING IS PALINDROME OR NOT

 

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
Void main()
{
     char str[80],rev[50];
     int len=0,j=0,i;
     clrscr();
     cout<<”Enter the string:”;
     gets(str);
     for(i=0;str[i]!=’\0’;i++)
     {
           len=len+1;
     }
     for(i=len-1;i>=0;i--)
    
     {
           rev[j]=str[i];
           j=j+1;
     }
    rev[j]=’\0’;
    puts(rev);
    if(strcmp(str,rev)==0)
        cout<<”String is palindrome”;
    else
        cout<<”String is not palindrome”;
     getch();

  }  

Comments

Popular Posts