Program to check whether given string is palindrome or not

Learn C++ (Introduction and Tutorials to C++ Programming)
//Program to check whether given string is palindrome or not
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
  void main()
  {clrscr();
  char str[30];
  int i,j,len,flag;
  cout<<"\n Enter The String :";
  gets (str);
  for(len=0; str [len]!='\0';++len);
  cout<<"\n The Length of The String ="<<len;
  for(i=0, j=len-1; i<len/2;i++,j--)
  {if(str[i]!= str[j])
  {flag =1;
  cout <<"\n NOT A PALINDROME";
  break;
  }
 }
 if(flag==0)
 cout<<"\n YES A PALINDROME";
 getch();
}
Program to check whether given string is palindrome or not Program to check whether given string is palindrome or not Reviewed by SHERE KHOJRAHA on February 14, 2019 Rating: 5

No comments:

Powered by Blogger.