Setbkcolor() Function

setbkcolor() function is used to set the background color in graphics mode. The default background color is black and default drawing color as we know is white.

Declaration

void setbkcolor(int color);
  • setbkcolor() function takes only one argument it would be either the name of color defined in graphics.h header file or number associated with those colors. If we write setbkcolor(GREEN) it changes the background color in Green.
  • For better understanding go through the program:

Program

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT, gm;

initgraph(&gd,&gm," ");

setbkcolor(GREEN);

circle(320,240,100);

getch();

closegraph();

}

The above program will change the background color to green by using setbkcolor() function and also display a circle of 100 cm radius of center(320,240) as given further:

Output

c graphics