2014 – Q20 (a)

A programming language provides the following pre-defined functions.

move(n) = distance moved in pixels

rotate(d) = degrees turned (positive means clockwise)

These can be used by the programmer to draw lines.

A programmer writes the code to draw a square. The code is shown below.

2014 q20 a

Write the code that would draw a hexagon. (3)

  • REPEAT 6 (1 mark)
  • move(n) (1 mark)
  • rotate(60) (1 mark)
  • END REPEAT

Unconditional loop (1 mark)
Movement of n (1 mark)
Rotation of 60 (1 mark)

Leave a Reply

Your email address will not be published. Required fields are marked *