Getmaxcolor() Function

getmaxcolor() is used to get the maximum color value.

Declaration

int getmaxcolor();
  • getmaxcolor returns the maximum color value. There are various colors that are also mentioned in graphics.h header file and the possible color values are from 0 - 15: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).
  • So getmaxcolor() function returns 15 that is the highest color value.
  • For better understanding go through the program:

Program

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT, gm,maxcolor;

char a[50];

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

maxcolor=getmaxcolor();

sprintf(a,"The maximum color value is:%d",maxcolor);

outtextxy(100,240,a);

getch();

closegraph();

}

The above program will return the highest possible color value and store it into integer type variable. Then the program will display a message as given in the output:

Output

c graphics