String palindrome

Description:

Overload ! operator to check string palindrom Test Case 1 Input (stdin) racecar Expected Output It is a palindrome Test Case 2 Input (stdin) madame Expected Output It is not a palindrome

Program :

#include<iostream>

#include<string.h>

using namespace std;

int main()

{

        char str[100];

        int i, length;

        int flag = 0;  

        cin>>str;  

        length = strlen(str);  

        for(i=0;i < length ;i++)

        {

         if(str[i] != str[length-i-1])

         {

         flag = 1;

         break;

        }

        }  

        if(flag)

        {

                cout<<"It is not a palindrome";

        }  

        else

        {

                cout<<"It is a palindrome";

        }

        return 0;

}