LOOP & COUT issue

as u mentioned the cout cannot be inside a loop why is it inside the while loop which we created in the second case.?

@Aryan-Sharma-2421953867913946 cout can be written anywhere inside int main as per requirements