change condition in if statement

1
2
3
4
5
6
7
bool x = false;

if(!x){
    x = true;
}else{
    printf("Hello!");
}


Shouldn't this program print "Hello!"?


This works fine,

1
2
3
4
5
6
7
8
bool x = false;

if(!x){
    x = true;
}
if(x){
    printf("Hello!");
}



Why does first code not working?
Last edited on
closed account (Eybjz8AR)
because if it matches the condition in the first statement it will skip the else statement completely because x is false.
So that means if first condition works, it skips all rest conditions?
yeah
Topic archived. No new replies allowed.