Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Coordinate System Exercises [11/11]

This program draws a line of green discs. The center of the first disc is at the left edge of the screen. The discs are drawn from left to right.

Exercise:

Exercise Coord 3 output image

Change the program so that the first disc is centered at the right edge of the screen. The discs should be drawn from right to left.

There are two ways to solve this problem, and you should try both. The first solution involves changing only the first line of the program. All three values of the for loop must be changed: the initial value, the bounding value and the step of loop. The step can be a negative value.

Solution

for #x = 960 .. 500 -=100

The second solution involves changing the coordinates of the disc function. First, you should reset the program to its original state by reloading this page. You can reload the page either by pressing the F5 key, by pressing the Ctrl-R key combination, or by clicking on the reload button of your browser.

In this second solution, you are only allowed to modify the call of the disc function.

Hint 1

Only the first argument of the disc function should be modified.

Hint 2

A subtraction operation needs to be performed.

Solution

disc(960-x, 300, 50, /green);

Click on the 'Articles' button at the top to select another article. We also suggest taking a peak into our main 'Gallery' of programs, and taking a look into 'Overview' of our main programming tutorial for beginners. Have fun!

Loading...