include files
stdio.h
stdlib.h
graphics.h
conio.h
math.h
void main()
{
float x,y,k,xa,xb,ya,yb,xinc,yinc,dx,dy,step;
int gdriver = DETECT, gmode, errorcode;
//int radius = 100;
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 4 values");
scanf("%f%f%f%f",&xa,&xb,&ya,&yb);
dx=xb-xa;
dy=yb-ya;
if(abs(dx) >abs(dy))
{
step=abs(dx);
}
else
{
step=abs(dy);
}
xinc=dx/step;
yinc=dy/step;
x=xa;
y=ya;
putpixel(x,y,1);
for(k=1;k< =step;k++)
{
x=x+xinc;
y=y+yinc;
putpixel(x,y,1);
}
getch();
}
No comments:
Post a Comment