C Program to draw circle using DDA algorithm

C Program to draw circle using DDA algorithm

# include <graphics.h> 
 # include<conio.h> 
# include<dos.h> 
#include<alloc.h> 
#include<math.h> 
void main() 
{ 
int gm,gd=DETECT,I,; 
int x,y,x1,y1,j; 
initgraph(&gd,&gm,””); 
x=40; /*The c0-ordinate values for calculating radius */ 
y=40; 
for(i=0;i<=360;i+=10) 
{ 
 setcolor(i+1); 
 x1=x*cos(i*3.142/180)+y*sin(i*3.142/180); 
y1=x*sin(i*3.142/180)-y*cos(I*3.142/180); 
circle(x1+getmaxx()/2,y1+getmaxy()/2,5); /* center of the circle is center 
of the screen*/ 
delay(10); 
} 
getch(); 
} 

Leave a Comment