Comparatus on string

as string is always comapared lexcographiclly then why this program is showing this output


acc to this apple should not be the output??

hello @dreamerekta
ur compare function will return true if first argument is lexicographically greater than second argument otherwise it will return false.

u are passing apple as first argument and mango as second argument.
because apple > mango is not true ur function will return false.
and hence else statement will execute.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.