You are here

rectangle function in c

Declaration: void rectangle(int left, int top, int right, int bottom);

rectangle function 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. The code given below draws a rectangle.

C programming code for rectangle

  1. #include<graphics.h>
  2. #include<conio.h>
  4. main()
  5. {
  6.    int gd = DETECT, gm;
  8.    initgraph(&gd, &gm, "C:\\TC\\BGI");
  10.    rectangle(100,100,200,200);
  12.    getch();
  13.    closegraph();
  14.    return 0;
  15. }