if
statements? What is the role of if
statements in programs?
pass_fail.c
that reads in an integer and prints out "PASS" if the integer is between 50 and 100 inclusive and fail if it is between 49 and 0, inclusive. It should print out ERROR if the number is less than 0, more than 100, or if the user does not enter a number. For example:
./pass_fail Please enter your mark: 42 FAIL ./pass_fail Please enter your mark: 50 PASS ./pass_fail Please enter your mark: 256 ERROR
rectangle_area.c
that reads in 2 integers
which are the side-length of a rectangle, and then prints the area of the rectangle.
For example:
./rectangle_area Please enter rectangle length: 3 Please enter rectangle width: 5 Area = 15 ./rectangle_area Please enter rectangle length: 42 Please enter rectangle width: 42 Area = 1764
Your tutor may still choose to cover some of the questions time permitting.
./even_or_odd Please enter a number: 42 EVEN ./even_or_odd Please enter a number: 111 ODD ./even_or_odd Please enter a number: -2 NEGATIVE