Have the following procedures
#include <stdio.h>Main () {intA=1, b=2, c=3, d=0;if(a==1&& b++==2)if(b!=2|| c--! =3) printf ("%d,%d,%d\n", a,b,c);Elseprintf"%d,%d,%d\n", a,b,c);Elseprintf"%d,%d,%d\n", a,b,c);}
The output after the program runs is 1 3 3
Else is always paired with the nearest if, so enter the first if statement in the conditional judgment, because it is the logic and operation need to both sides of the operand value is not 0 value, it is true, so need to execute the result is 1, no longer perform the operation in the second case statement? Instead, enter the second if statement condition to judge , because the b!=2 condition is true, the value of the entire conditional expression is real, so the value of the second operand (c--! =3) of c is no longer executed, and the first else statement is no longer executed? Print the value of a 1,b value of 3,c 3?
Order of Operations