You are viewing this question as it will appear in the manual grading interface.
Return to the normal view when
you are done.
Correct answer
Click to reveal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Draws a right-angled, isosceles triangle on the screen * where: (i) the length of the equal/shorter sides * (i.e., not the hypotenuse), and (ii) the (x, y) location * of the upper vertex are passed as parameters. */ void drawTri(int side_length, int x, int y) { /* * We know that if we can find the coordinates of the 3 vertices, * then we can use the drawLine function to draw the triangle. * The coordinates of the first vertex are given as parameters of * the function. The coordinates of the other two vertices need to * be computed. */ int v1x = x; int v1y = y; int v2x = v1x; int v2y = v1y - side_length; int v3x = v2x + side_length; int v3y = v2y; // call drawLine to draw the triangle on the screen drawLine(v1x, v1y, v2x, v2y); drawLine(v2x, v2y, v3x, v3y); drawLine(v3x, v3y, v1x, v1y); } |
Student view placeholder
In student views this area is used for assessment and score info.
Tools
Staff information
Variant
Started at:
2026-09-19 11:10:59 (CDT)
Duration:
0s
Show/Hide answer
{}