setcolor in C++ graphics by R4R Team

setcolor() function is used to change the color of the graphics objects.

Syntax-
setcolor(color)

Without setcolor:

program-

#include< stdio.h>
#include< conio.h>
#include< graphics.h>
void main()
{
int gd=DETECT,gm=0;
initgraph(&gd,&gm,"");
line(100,100,300,100);
circle(150,200,50);
getch();
}


output:



With Setcolor(RED):

program-

#include< stdio.h>
#include< conio.h>
#include< graphics.h>
void main()
{
int gd=DETECT,gm=0;
initgraph(&gd,&gm,"");
setcolor(RED);
line(100,100,300,100);
circle(150,200,50);
getch();
}


output-



With Setcolor(GREEN):

program-

#include< stdio.h>
#include< conio.h>
#include< graphics.h>
void main()
{
int gd=DETECT,gm=0;
initgraph(&gd,&gm,"");
setcolor(GREEN);
line(100,100,300,100);
circle(150,200,50);
getch();
}

output:




Leave a Comment: