0

When (IF) is terminated by semi- colon why it doesn't execute infinite times

int main() { int x = 2; if(x == 2); x=0; if(x == 3) x++; else x +=2; printf("x= %d", x); return 0; }

28th Apr 2020, 1:12 PM
AR Z
3 odpowiedzi
+ 3
;ends an command and so the command after tze first x is just ; means do nothing
28th Apr 2020, 1:15 PM
Alexander Thiem
Alexander Thiem - avatar
+ 1
hmm yeah you probably did, but still the question has its meaning
28th Apr 2020, 1:21 PM
Alexander Thiem
Alexander Thiem - avatar
0
I guess I mixed loops with conditionals Thank you😊
28th Apr 2020, 1:21 PM
AR Z