// circles.cxx // draws random circles on the screen #include // for graphics functions #include // for random() const int XDIM = 500; const int YDIM = 500; void main(void) { int xcenter, ycenter;// center of circle int radius; // radius of circle int col; initwindow(XDIM, YDIM); // open a graphics window while (!kbhit()) { // loop until any key is hit on the keyboard do { // pick a random location and radius for the circle xcenter = random(XDIM-1); // random number for x center ycenter = random(YDIM-1); // random number for y center radius = random(101) + 50; // random number in range 50-150 } while (xcenter+radius >= XDIM || xcenter-radius < 0 || ycenter+radius >= YDIM || ycenter-radius < 0); // make sure circle lies entirely on screen col = random(16); // choose a random color setcolor(col); // set color for circle circle(xcenter, ycenter, radius); // draw unfilled circle //delay(100 /* milliseconds */); } }