The program is to draw an animated circle in computer graphics . The header file used for using graphics in C code is #include<graphics.h> , This graphics functions are included in this header file. The functions like circle, rectangle, arc, eclipse etc all are included in the graphics header file. It is required to declare this header file in the beginning of the program to use these inbuilt functions. The graphics need to be initialized after the main function is defined .The graphics are initialized using initgraph function.In initgraph function the path of the BGI directory is given .
Program to draw an animated circle
#include<iostream.h>#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
int x,y;
initgraph(&gd,&gm,"c:/tc/bgi");
setbkcolor(RED);
x=getmaxx()/2;
y=getmaxy()/2;
while(!kbhit())
{
for(int i=1;i<=15;i++)
{
for(int p=400;p>=1;p--)
circle(x,y,p);
}
setcolor(i+2);
for(int r=1;r<400;r++)
{
circle(x,y,r);
}
}
}
getch();
}