Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

The if Statement [13/16]

This program draws 2000 small discs. The discs to the right of line x=300 and above line y = 500 are painted in red, and the other ones are in blue.

Exercise:

Exercise if statement 13-1 output image

Imagine a rectangle in the middle of the screen with the left edge at x = 200 , right edge at x = 760 , top edge at y = 170 and bottom edge at y = 550 . Modify the given program such that only the discs whose centers lie in the descibed rectangle are painted in red, and other discs in blue.

Solution

	if x>200, x<760, y>170, y<550
		: mycolor = /red;

Loading...