






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







scanf("%d", &pressureValue);
while (pressureValue <= MAX_PRESSURE) { if (pressureValue == NOMINAL_VALUE) printf("Pressure is nominal\n"); else printf("Pressure is %d pounds\n", pressureValue);
for (i = 5; i <= pressureValue ; i = i + 10) printf("+");
printf("\n"); scanf("%d", &pressureValue); } // End while Docsity.com
any valid mathematical expression
logical operators
function calls that return a value
==,!= Equivalent, Not equivalent
<, <= Less than, Less than or equals
, >= Greater than, Greater than or equals
if (0 || 0) printf("Does false OR false = true?");
if (0 && 0) printf("Does false AND false = true?");
ch1 = 'a'; ch2 = 'a'; printf("ch1 OR ch2 = %d\n", ch1 || ch2); // 1 printf("ch1 AND ch2 = %d\n", ch1 && ch2); // 1
ch1 = 'd'; ch2 = 'f'; printf("ch1 OR ch2 = %d\n", ch1 || ch2); // 1 printf("ch1 AND ch2 = %d\n", ch1 && ch2); // 1
ch1 = 'a'; ch2 = '\0'; printf("ch1 OR ch2 = %d\n", ch1 || ch2); // 1 printf("ch1 AND ch2 = %d\n", ch1 && ch2); // 0
evaluated in an expression
are evaluated before other operators (i.e., unary before binary operators, multiplication before addition, relational operators before logical operators)
Rule of thumb: Avoid complicated
expressions and use parentheses
declare them of type int
if (valueFound == TRUE) X = 5; // Bad practice if (valueFound) X = 5; // Good practice
if (valueFound == FALSE) X = 5; // Bad practice if (!valueFound) X = 5; // Good practice