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:
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!