include files
stdio.h
stdlib.h
graphics.h
conio.h
math.h
void main()
{
int x,y,p,xa,xb,ya,yb,xend,dx,dy,x1,x2,y1,y2;
int gdriver = DETECT, gmode, errorcode;
clrscr();
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
printf("Enter the values");
scanf("%d%d%d%d",&xa,&xb,&ya,&yb);
dx=abs(xb-xa);
dy=abs(ya-yb);
p=2*(dy-dx);
if(x1 >x2)
{
x=x2;
y=y2;
xend=x1;
}
else
{
x=x1;
y=y1;
xend=x2;
}
putpixel(x,y,1);
while(x< xend)
{
if(p< 0)
{
x=x+1;
y=y;
p=p+2*dy;
}
else
{
y=y+1;
x=x+1;
p=p+2*(dy-dx);
}
putpixel(x,y,1);
}
getch();
}
Google Ads
Monday, May 18, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment