C++ Programming Code Examples
Learn C++ Language
rectangle() Function in C++ Programming Language
rectangle() Function in C++
rectangle() is used to draw a rectangle. Coordinates of left top and right bottom corner are required to draw the rectangle. left specifies the X-coordinate of top left corner, top specifies the Y-coordinate of top left corner, right specifies the X-coordinate of right bottom corner, bottom specifies the Y-coordinate of right bottom corner.
Syntax for rectangle() Function in C++
rectangle(int left, int top, int right, int bottom);
left
X coordinate of top left corner.
top
Y coordinate of top left corner.
right
X coordinate of bottom right corner.
bottom
Y coordinate of bottom right corner.
To create a rectangle, you have to pass the four parameters in this function. The two parameters represent the left and top upper left corner. Similarly, the right bottom parameter represents the lower right corner of the rectangle.
This function does not return any value.
/* function rectangle() draws a rectangle in graphic mode. */
int main()
{
// location of left, top, right, bottom
int left = 150, top = 150;
int right = 450, bottom = 450;
// initgraph initializes the graphics system
// by loading a graphics driver from disk
initgraph(&gd, &gm, "");
// rectangle function
rectangle(left, top, right, bottom);
left = 200, = 250;
right = 150, = 300;
rectangle(left, top, right, bottom);
left = 100, = 200;
right = 450, = 100;
rectangle(left, top, right, bottom);
getch();
return 0;
}
In C++, a namespace ("the name scope") is an abstract container or environment created to hold a logical grouping of "unique identifiers" or symbols (i.e., names). An identifier defined
This algorithm takes the input of the number of 'Vertexes' and their corresponding degree. Checks various 'constraints', tries to build the graph. If it fails, no valid graph can be created