String STL Doubt

Find the output of the following program.

void f(){

    string s=”abhuhba”     ;   
    bool flag=false;
    for(int i=0;i<s.length()/2;i++)
         if(s[i]!=s[s.length()-1-i])flag=false;          
         if(flag)cout<<”YES”;         

        else cout<<”NO”;

    }

@Kinjal whats the doubt whats your answer?

I mean, NO is my option.

@Kinjal yes its NO only as flag is set to false

But, I was wrong. They tell me that it should be YES.

@Kinjal well maybe then there is typo error flag should be set to true. you can run this on your compiler also ans is NO

You can see that.

@Kinjal i will inform the team about it

so should I have to pick wrong answer to get my points now?

@Kinjal no bro there is some mistake in the question , i will inform the team , they will update it

okay. Doubt resolved. Thank you.

you are welcome :smiley: