#includeint main() { initwindow(500, 500); // create a 500x500 window setcolor(WHITE); // set background color to white bar(0, 0, 500, 500); // fill the window with white setcolor(BLACK); // set pen color to black rectangle(50, 50, 200, 150); // draw a rectangle at (50, 50) with width 150 and height 100 getch(); closegraph(); // close window return 0; }
#includeThese examples use the graphics.h library, which is part of the BGI (Borland Graphics Interface) package. However, this library is not supported on modern operating systems. To use graphics in a modern C++ environment, you can use third-party libraries such as SDL, SFML, or OpenGL.int main() { initwindow(500, 500); // create a 500x500 window setcolor(BLUE); // set pen color to blue rectangle(50, 50, 200, 150); // draw a rectangle at (50, 50) with width 150 and height 100 setfillstyle(SOLID_FILL, RED); // set fill color to red floodfill(100, 100, BLUE); // fill the rectangle with red getch(); closegraph(); // close window return 0; }