what will bw the output of this code? c++ [closed]

int k = i * 10; and int k = i++; are declarations of k that shadow the outer k. The statement std::cout << k; in the outer scope therefore always outputs zero.

The only effect of the if body is to increase i by 1. And it only does that if i is zero (or less). That value of i is returned printed.

Thus the output is 01.01. Armed with a line by line debugger, the shadowing effect will be obvious.