Home  >  Article  >  Backend Development  >  In the C graphics library, the bar() function is used to draw a rectangular bar

In the C graphics library, the bar() function is used to draw a rectangular bar

WBOY
WBOYforward
2023-09-10 14:25:011304browse

bar() function is a C graphics function used to draw graphics in the C programming language. The graphics.h header file contains functions for drawing graphics. The bar() function is also defined in the header file.

Syntax

void bar(int left, int top, int right, int bottom);

The bar() function is used to draw a bar (bar chart) , it is a two-dimensional graph. It is a filled rectangular shape. This function accepts four parameters, namely the (X, Y) coordinates of the upper left corner of the bar {left and top} and the (X, Y) coordinates of the lower right corner of the bar {right and bottom}.

Program

#include <graphics.h>
#include <conio.h>

int main() {
   int gd = DETECT, gm;
   initgraph(&gd, &gm, "C:\TC\BGI");
   bar(120, 120, 250, 250);
   getch();
   closegraph();
   return 0;
}

Output

In the C graphics library, the bar() function is used to draw a rectangular bar

The above is the detailed content of In the C graphics library, the bar() function is used to draw a rectangular bar. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete