Condition in the elseif condition

when will we face a situation like s.top!=’)’ in the problem

If you not put this condition, then also code will work.