C programme to draw a Rainbow

In C Graphics we use graphics.h functions. This is used to draw different shapes(like circle,rectangle etc),display text(any message)in different format(different fonts and colors).By using graphics.h we can make programs, animations and also games. We have to call initgraph function which will initialize the graphics mode.






void main()


//auto detection

       int gdriver = DETECT,gmode;

       int x,y,i;

       //initialize graphics mode(passed three arguments to initgraph function)

       initgraph(&gdriver,&gmode,"C:\\Turboc3\\BGI");/*&gdriver is the address of gdriver variable,&gmodeis the address of gmode and ,"C:\\Turboc3\\BGI" is the path where BGI files are stored.*/











rainbow in c


DETECT is a macro defined in graphics.h which requests initgraph() method to automatically determine which graphics driver to load.

Getmaxx() This function is used only to get the maximum value of X coordinate

Getmaxy() This function is used only to get the maximum value of Y coordinate.

About Us

Rekha SetiaRekha Setia is a passionate blogger of Extra Computer Notes. if you have any ideas or any request me @