Flag

Why have we used boolean flag in this, cannt we just put true/false condition in if block ang get answer without using flag?