the assignment operator (=), instead of the equality operator (==) Still compiles, so it is a difficult bug to find! And it will change the value of the 1st operand int num3 = 3, num5 = 5; printf(“%d\n”,num3=num5); //5
0==x For the C language, zero is false And anything non-zero is true Determines if x is equal to zero, or not equal to zero int zero = 0, num5 = 5; printf(“%d\n”,!zero); //1 printf(“%d\n”,!num5); //0
differences in floating point numbers, do not use the equality operator (==) to compare two floating points double threshold = 0.00001; if(fabs(number) < threshold){ printf(“Close to zero”); }
not take any shortcuts to writing relational and logical statements Do not write If a<b is false, the condition becomes: if( 0 < c) If a<b is true, the condition becomes: if( 1 < c) if(a < b < c) if((a < b)&&(b < c))
the structure If no break statement is present ALL the code within the switch statement will execute, beginning in the matching case and ending whenever a break statement is found or the switch statement ends