Program to check whether given string is palindrome or not

Tuesday, August 11, 2020

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();

}

You Might Also Like

0 Comments

Like us on Facebook

Flickr Images

Flickr Short Films