Friday 18 November 2011

How to Initialize Graphics mode in C language

/*Header Files*/
#include<stdio.h>                  //for input/output purpose
#include<conio.h>                 //for getch() function
#include<graphics.h>            //for graphics functions
void main()
{
         int driver=DETECT, mode;                               //auto detect the driver
         int x=320, y=240, radius=100;                            // initialization
           initgraph(&driver , &mode , "c:\\tc\\bgi");  // all necessary graphics files in BGI folder
                  circle(x , y, radius);                                            //create a circle
         getch();                                                          // waits for key press
         closgraph();                                                    //close graphics mode
}

The above program will give the following output: