How to Use Setbkcolor in C or C++ Graphics

set bk color

Introduction :

In this article I will show you how to change current background color by C or C++ using Setbkcolor function in graphics mode. setbkcolor is built-in function in graphics header

Declaration :

void setbkcolor(int color);

How to use :

For use this function you have to install turboc++ .

Generally graphics background color is BLACK. There are 16 color in graphics.h . The following color are defined in graphics.h

Name with Value
BLACK 0
BLUE 1
GREEN 2
CYAN 3
RED 4
MAGENTA 5
BROWN 6
LIGHTGRAY 7
DARKGRAY 8
LIGHTBLUE 9
LIGHTGREEN 10
LIGHTCYAN 11
LIGHTRED 12
LIGHTMAGENTA 13
YELLOW 14
WHITE 15

C programming code for setbkcolor where all background color change automatically. Now copy the following code and paste in turboc++.

/*Developed by Puskar Jasu*/
#include <graphics.h>
#include <conio.h>
#include <dos.h>
main()
{
    int i;
    int graphic_driver = DETECT, graphic_mode;
    initgraph(&graphic_driver, &graphic_mode, "//turboc3/bgi");
    for (i = 0; i <= 15; i++)
    {
        setbkcolor(i);
        delay(400);
    }
    getch();
    closegraph();
    return 0;
}

Conclusion :

In this article I show you how you use setbkcolor in turboc++. Thanks for visit my site.

You can see my following project :

You can see my following program :

Scroll to Top