Draw Rainbow



You can imagine you can also draw a colorful rainbow with the help of c-graphics funtion.It includes a c-graphics code to draw a rainbow on your output screen.Here is the code to draw the rainbow:

#include<stdio.h>

#include<conio.h>

#include<dos.h>

#include<graphics.h>

#include<stdlib.h>

void main()

{

int gd=DETECT,gm,f=80,h=15,l=15,k=0,i;

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

setcolor(LIGHTBLUE);

/*clouds*/

setlinestyle(0,0,1);

ellipse(220,70,60,240,10,15);

ellipse(245,60,345,165,20,15);

ellipse(282,67,340,160,20,15);

ellipse(288,86,230,50,20,15);

ellipse(246,93,163,340,31,15);

ellipse(320,63,20,182,21,19);

ellipse(345,72,290,100,21,15);

ellipse(319,90,228,20,33,15);

setcolor(WHITE);

arc(300,300,0,180,20);

arc(300,300,0,180,40);

arc(300,300,0,180,60);

arc(300,300,0,180,80);

arc(300,300,0,180,100);

arc(300,300,0,180,120);

arc(300,300,0,180,140);

arc(300,300,0,180,160);

line(140,300,280,300);

line(320,300,460,300);

setfillstyle(SOLID_FILL,MAGENTA);

floodfill(270,280,WHITE);

setfillstyle(SOLID_FILL,LIGHTCYAN);

floodfill(250,280,WHITE);

setfillstyle(SOLID_FILL,GREEN);

floodfill(230,280,WHITE);

setfillstyle(SOLID_FILL,YELLOW);

floodfill(210,280,WHITE);

setfillstyle(SOLID_FILL,LIGHTMAGENTA);

floodfill(190,280,WHITE);

setfillstyle(SOLID_FILL,LIGHTBLUE);

floodfill(170,280,WHITE);

setfillstyle(SOLID_FILL,LIGHTRED);

floodfill(150,280,WHITE);

getch();

closegraph();

}



The above code is used to to draw a rainbow on the output screen.In the above program we have used the various functions like arc,ellipse,line on order to draw rainbow.setfillstyle and floodfill functions are used for filling the color in rainbow.To learn more about these function you can visit our tutorial Graphics in C.The output of the above program will look like as follows:



Output

c_graphics