This assignment is due in class or to my office assistant in RRO 215 by 9:30 AM on 20 November.
Use the following structure and enumerated type C declarations in this assignment.
typedef struct { int lo ; int hi ; } range ; typedef enum { BELOW, INSIDE, ABOVE } position ;
Question 1
Write small sections of code to perform the following tasks.
- Declare
i
and j to be integer variables. - Declare
R
to be a variable of typerange
. - Declare
P
to be a variable of typeposition
. - Write statement(s) to initialize
R
. - Write statement(s) to initialize
P
. - Write statement(s) that set
i
to the value of fieldlo
ofR
. - Write statement(s) that set
j
to 1, ifP
has the valueINSIDE
. - Write statement(s) that increase
field
hi
ofR
by 3. - Declare
pR
to be a pointer to a variable of typerange
. - Set
pR
to be a pointer toR
.
Question 2
Write a function that receives a variable of type position
and returns an integer. The function should return 0, if it is passed
INSIDE
, and should return 1, otherwise.
Question 3
Write a function that is passed a pointer to
a variable of type range
.
The function should set both fields of the referenced
range
type to 255.