Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include // (a) Declare four global integer variables, as follows: // x - the horizontal location of the left edge of the rectangle

image text in transcribed

image text in transcribed

#include #include #include

// (a) Declare four global integer variables, as follows: // x - the horizontal location of the left edge of the rectangle // y - the vertical location of the top edge of the rectangle // w - the width of the rectangle. // h - the height of the rectangle.

// (b) Declare a global variable of type char called c. // This is the character that is to be used to render the rectangle.

void draw_rect(void) { // (c) Insert code to draw the outline of the rectangle defined by the global variables. // If either of the width or height is less than or equal to zero, // the function must not draw anything. }

int main(void) { setup_screen();

// draw a box. x = rand() % screen_width() / 2; y = rand() % screen_height() / 2; w = 1 + rand() % (screen_width() - x - 1); h = 1 + rand() % (screen_height() - y - 1); c = '@'; draw_rect(); show_screen();

// draw a box. x = rand() % screen_width() / 2; y = rand() % screen_height() / 2; w = 1 + rand() % (screen_width() - x - 1); h = 1 + rand() % (screen_height() - y - 1); c = '&'; draw_rect(); show_screen();

// draw a box with zero width. x = rand() % screen_width() / 2; y = rand() % screen_height() / 2; w = 0; h = 1 + rand() % (screen_height() - y - 1); c = '*'; draw_rect(); show_screen();

// draw a box. x = rand() % screen_width() / 2; y = rand() % screen_height() / 2; w = 1 + rand() % (screen_width() - x - 1); h = 1 + rand() % (screen_height() - y - 1); c = '#'; draw_rect(); show_screen();

// draw a box with negative width. x = rand() % screen_width() / 2; y = rand() % screen_height() / 2; w = -rand() % screen_width(); h = 1 + rand() % (screen_height() - y - 1); c = '!'; draw_rect(); show_screen();

// draw a box. x = rand() % screen_width() / 2; y = rand() % screen_height() / 2; w = 1 + rand() % (screen_width() - x - 1); h = 1 + rand() % (screen_height() - y - 1); c = '+'; draw_rect(); show_screen();

// draw a box with zero height. x = rand() % screen_width() / 2; y = rand() % screen_height() / 2; w = 1 + rand() % (screen_width() - x - 1); h = 0; c = 'a'; draw_rect(); show_screen();

// draw a box. x = rand() % screen_width() / 2; y = rand() % screen_height() / 2; w = 1 + rand() % (screen_width() - x - 1); h = 1 + rand() % (screen_height() - y - 1); c = 'b'; draw_rect(); show_screen();

// draw a box with negative width. x = rand() % screen_width() / 2; y = rand() % screen_height() / 2; w = -rand() % screen_width(); h = 1 + rand() % (screen_height() - y - 1); c = 'c'; draw_rect(); show_screen();

// draw a box. x = rand() % screen_width() / 2; y = rand() % screen_height() / 2; w = 1 + rand() % (screen_width() - x - 1); h = 1 + rand() % (screen_height() - y - 1); c = 'd'; draw_rect(); show_screen();

timer_pause(5000); cleanup_screen(); return 0; }

image text in transcribed

omplete the implementation of the draw_rect function. This function augments the ZDK by adding the ability to draw rectangular boxes. The hash-tags for this exercise are: cab202 and #cab202DrawRect1. This exercise will give you practice with the drawing functions in the ZDK and the use of global variables to transfer data between functions. Given the definition of a rectangle, you will complete a function that draws the outline of the rectangle using pre-existing functions defined in the ZDK. This function does not return a result. To complete the program, follow the instructions detailed in the in-line comments in the draw_rect () function

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions