Skip to main content
Logo image

Section 26.5 Dynamic Arrays of Structures: Pentagon

Subsection 26.5.1 Declare Vertices

Activity 26.6.

Use the function createPolygon to create a pentagon (5 vertices) with vertices (0,0), (1,0), (2,1), (1,3), (0,1).

admin.....open in new window

When you are done, please paste your code into the code submission box below:

Subsection 26.5.2 Print Pentagon

Activity 26.7.

Finally... Write a function printPoly() to which you pass a polygon and a number (its number of vertices), and which prints out these vertices.

admin.....open in new window

When you are done, please paste your code into the code submission box below:

Subsection 26.5.3 Don’t forget to free()!

Activity 26.8.

One last step, free the allocated memory!

admin.....open in new window

When you are done, please paste your code into the code submission box below: