Struct A

Warmup

  1. Create a structure called pqr with fields x, y, z, and w.

Struct A

Given that:

  • x and y are numbers
  • z is a color
  • w? is a boolean
  1. Make a variable ex1 that holds a pqr with x=10, y=20, z="blue", and w? is false.

  2. Make a variable ex2 that has a posn representing (110, 80).

  3. Give the values of:

    • (posn? ex1)
    • (pqr? ex1)
  4. Make ex3 a pqr with different fields from ex1.

  5. Write the inventory for ex1 showing where every value comes from.

    • 10
    • 20
    • z
    • false
  6. Write a function that puts a “z” color circle at (x,y). Bonus: make the circle solid when w? is true and otherwise outline.

    1. Example code using the information from ex1.
    2. Work backwards to use a variable.
Last modified February 20, 2025: Struct-focused review exercises. (b2c97fb)