Respuesta :
Answer:
Answer explained below with appropriate steps and C++ code
Explanation:
Step 1:
- Two corner points to draw a rectangle are left top and right bottom corner coordinates.
- Left and top specifies the X-coordinate and Y-coordinate of top left corner respectively.
- Right and bottom specifies the X-coordinate and Y-coordinate of right bottom corner respectively.
- Library graphics.h is declared to use different graphical operations.
- Member function rectangle() is called 4 times to represent 4 rectangles.
Step 2:
// Program to draw a rectangle using graphics header
#include<graphics.h>
#include<conio.h>
#include<iostream>
int main ()
{
//To clear the screen
clrscr ();
//gm is used so that program can enter into graphic mode.
int gm;
//DETECT is used to tell the compiler that which graphics drivers need to be used
int grap = DETECT;
//Location of 4 rectangles
int left = 150, top = 250, right = 450, bottom = 350;
int l1 = 150, t1 = 150, r1 = 450, b1 = 450;
int l2 = 250, t2 = 350, r2 = 450, b2 = 150;
int l3 = 250, t3 = 150, r3 = 350, b3 = 450;
//initgraph function is used to reset the settings of graphics to their default settings.
initgraph (&grap, &gm, "");
// rectangle function is called
rectangle (left, top, right, bottom);
rectangle (l1, t1, r1, b1);
rectangle (l2, t2, r2, b2);
rectangle (l3, t3, r3, b3);
getch ();
//closegraph function is used to close all the settings that was revoked by gm and initgraph().
closegraph ();
return 0;
}