Search This Blog

C Program to Draw Rainbow - Computer Graphics Pogram

This is a simple computer graphics lab program in c language to display a rainbow. Since BGI (Borland Graphics Interface) supports only 16 colors, the rainbow cannot be shown in correct colors (VIBGYOR). This is because, colors like violet, indigo and orange are not available in BGI. There fore, we just use some available color instead. The following is the program.

#include<stdio.h>
#include<graphics.h>

void main()
{
int gd=DETECT,gm,i=0,a=0;
float r=20;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI\\");

for(i=1;i<100;i++)
 {
 if(a!=i/15)
  delay(300);
 a=i/15;
 setcolor(a);
 arc(200,150,10,170,r+i);
 }
getch();
}



No comments: