String is a Palindrome or not - Learn Engineering

All the news and updates relevant to Engineering. You can also Write a post here

Breaking

Friday, June 26, 2020

String is a Palindrome or not

C++ PROGRAM TO FIND WHETHER THE STRING IS PALINDROME OR NOT

Sample Test Case    :    Enter the String : Madam

Sample Output    :  Madam is a Palindrome

CODE

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char  str1[20],str2[20];
    int i,j,len=0,flag=0;
    cout<<"Enter the String :";
    gets(str1);
    len=strlen(str1)-1;
    for(i=len,j=0,i>=0;i--,j++)
    str2[j]==str1[i];
    if(strcmp(str1,str2))
    flag==1;
    if(flag==1)
    cout<<str1<<"is a Palindrome";
    else
    cout<<str1<<"is not a Palindrome";
    return 0;
}

No comments:

Post a Comment