**#include<stdio.h>**

**#include<conio.h>**

**#include<graphics.h>**

**void main()**

**{**

**int gd=DETECT,gm;**

**int x,y,x1,x2,y1,y2,dx,dy,e,m,k;**

**clrscr();**

**initgraph (&gd,&gm,"C:\\TC\\BGI");**

**printf("Enter the co-ordinates of the first point \n");**

**printf("x1= ");**

**scanf("%d/n",&x1);**

**printf("y1= ");**

**scanf("%d/n",&y1);**

**printf("Enter the co-ordinates of the second point \n");**

**printf("x2= ");**

**scanf("%d/n",&x2);**

**printf("y2= ");**

**scanf("%d/n",&y2);**

**clrscr();**

**dx= x2-x1;**

**dy= y2-y1;**

**m=(float)dy/dx;**

**e=m-0.5;**

**x=x1;**

**y=y1;**

**for(k=1;k<=dx;k++)**

**{**

**putpixel (x,y,RED);**

**while(e>0)**

**{y++;**

**e--;**

**}**

**x++;**

**e=e+m;**

**}**

**getch();**

**closegraph();**

**}**

Sign up here with your email

## 2 comments

Write commentsBresenham circle generation algo

Reply# include-stdio.h-

# include-conio.h-

# include-graphics.h-

# include-math.h-

void main()

{

int gd=DETECT,gm;

int r,x,y,p,xc=320,yc=240;

initgraph(&gd,&gm,"C:\\TC\\BGI");

cleardevice();

printf("Enter the radius ");

scanf("%d",&r);

x=0;

y=r;

putpixel(xc+x,yc-y,1);

p=3-(2*r);

for(x=0;x<=y;x++)

{

if (p<0)

{

y=y;

p=(p+(4*x)+6);

}

else

{

y=y-1;

p=p+((4*(x-y)+10));

}

putpixel(xc+x,yc-y,1);

putpixel(xc-x,yc-y,2);

putpixel(xc+x,yc+y,3);

putpixel(xc-x,yc+y,4);

putpixel(xc+y,yc-x,5);

putpixel(xc-y,yc-x,6);

putpixel(xc+y,yc+x,7);

putpixel(xc-y,yc+x,8);

}

getch();

closegraph();

}

http://www.spandan2013.com/

Replyhttp://www.rscoeinnovision.com/

more fests details on "www.knowafest.com"

ConversionConversion EmoticonEmoticon