C graphics program to set background color.
The following table shown color name and it corresponding int value.
#include <graphics.h>
#include <stdio.h>
int main( )
{
int gd=DETECT, gm;
initgraph(&gd,&gm,"C:\\tc\\bgi");
setbkcolor(1);
getch();
closegraph();
return 0;
}
- General syntax to set background color is
setbkcolor(int color). - bkcolor is used to set background color of the screen.
- Its take only one argument it may be a int or char data type.
- In setbkcolor function we can choose color by its int value(0-15) or by color name
The following table shown color name and it corresponding int value.
Color | int 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 program to set background
#include <graphics.h>
#include <stdio.h>
int main( )
{
int gd=DETECT, gm;
initgraph(&gd,&gm,"C:\\tc\\bgi");
setbkcolor(1);
getch();
closegraph();
return 0;
}
Download |
---|
0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.