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
iand j to be integer variables. - Declare
Rto be a variable of typerange. - Declare
Pto be a variable of typeposition. - Write statement(s) to initialize
R. - Write statement(s) to initialize
P. - Write statement(s) that set
ito the value of fieldloofR. - Write statement(s) that set
jto 1, ifPhas the valueINSIDE. - Write statement(s) that increase
field
hiofRby 3. - Declare
pRto be a pointer to a variable of typerange. - Set
pRto 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.