Review Questions
Determine which expressions are true and which are false.
100 > 3 && `a'>`c'
100 > 3 || `a'>'c'
!(100>3)
Construct an expression to express the following conditions:
number is equal to or greater than 1 but smaller than 9.
ch is not a q or a k character.
number is between 1 and 9 but is not a 5.
number is not between 1 and 9.
The following program has unnecessarily complex relational expressions as well as some outright errors. Simplify and correct it.
#include <stdio.h> int main(void) /* 1 */ { /* 2 */ int weight, height; /* weight in lbs, height in inches */ /* 4 */ scanf("%d, weight, height); /* 5 */ if (weight < 100) /* 6 */ if (height >= 72) /* 7 */ printf("You are very tall for your weight.\n"); else if (height < 72 && ...
Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.