Color models convert between RGB Color in Computer Graphics

Aim
To implement the color models using c/c++ program RGB Color in C program CS1355-Graphics & Multimedia Lab
Algorithm
Start the program for Color Model
Include the necessary package
Get the character by through getche() function
Depends upon there key value increase there RGB range in appropriate rectangular box
Using the following function
setrgbpalette(1,R,G,B);
setfillstyle(1);

bar(x,y,x1,y2);
Rectangle(x1,y1,x2,y2);
Draw the color model
Finally terminate the color model program

Source code program in C using Graphics function for Color Model
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
void main()
{
int gd=DETECT,gm,n;
float r=0,g=0,b=0;
float y=0,i=0,q=0;
float c=0,m=0,y1=0;
initgraph(&gd,&gm,"");
printf("(r,g,b)keys for incrementing R,G,B values respectively\n");
printf("(shift+(r,g,b))keys for decrementing R,G,B values respectively\n");
printf("press esc to exit\n");
setcolor(15);
while(1)
{
gotoxy(18,10);
printf("R G B");
c=1.0-r;
m=1.0-g;
y1=1.0-y;
gotoxy(47,10);
printf("C M Y");
y=0.299*r+0.587*g+0.144*b;
i=0.596*r-0.275*g-0.3218*b;
q=0.212*r-0.528*g+0.311*b;
gotoxy(18,23);
printf("Y I Q");
switch(getche())
{
case 'r':
r++;
break;
case 'g':
g++;
break;
case 'b':
b++;
break;
case 'R':
r--;
break;
case 'G':
g--;
break;
case 'B':
b--;
break;
case 27:
closegraph();
exit(0);
}
if(r>255)
r=0;
if(g>255)
g=0;
if(b>255)
b=0;
setrgbpalette(1,r,g,b);
setfillstyle(1,1);
bar(50,50,270,250);
rectangle(50,50,270,250);
setrgbpalette(2,c,m,y1);
setfillstyle(1,2);
bar(275,50,495,250);
rectangle(275,50,495,250);
setrgbpalette(3,y,i,q);
setfillstyle(1,3);
bar(50,255,270,455);
rectangle(50,255,270,455);
}
}
Output color model in RGB color Red, Green Blue

Color models convert between RGB Color in Computer Graphics