Program to Draw a line #include<graphics.h> #include<stdio.h> #include<conio.h> void main(void) { int gdriver = DETECT, gmode; int x1 = 200, y1 = 200; int x2 = 300, y2 = 300; clrscr(); initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi"); line(x1, y1, x2, y2); getch(); closegraph(); } Code Explanation- The first step in any graphics program is to include graphics.h header file. The graphics.h header file provides access to a simple graphics library that makes it possible to draw lines, rectangles, ovals, arcs, polygons, images, and strings on a graphical window. The second step is initialize the graphics drivers on the computer using initgraph method of graphics.h library. void initgraph(int *graphicsDriver, int *graphicsMode, char *driverDirectoryPath); It initializes the graphics system by loading the passed graphics d...
Comments
Post a Comment