I\'ve been thinking of some beginner mistakes and I ended up with the one on the if statement. I expanded a bit the code to this:
if
int i = 0; if
Assuming your code actually looks like this:
#include using namespace std; int main() { int i = 0; if (i = 1 && i == 0) { cout << i; } }
Then this:
if (i = 1 && i == 0) {
evaluates as
if (i = (1 && i == 0)) {
and so i is set to 1.
i
1