Untitled
raw download clone
TEXT
views 22
,
size 647 b
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

void main()

{
int dx,dy,p,x,y;
int x0,y0,x1,y1;
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;

   /* initialize graphics mode */
   initgraph(&gdriver, &gmode, "C:\\TC\\BGI");

printf("Enter stating co-ordinates:\n");
scanf("%d%d",&x0,&y0);
printf("Enter ending co-ordinates:\n");
scanf("%d%d",&x1,&y1);

dx=x1-x0;
dy=y1-y0;
x=x0;
y=y0;
p=(2*dy)-dx;
while(x<x1)
{
if(p<0)
{
 putpixel(x,y,RED);
p=p+(2*dy);
}
else{
 putpixel(x,y,RED);
p+=(2*dy)-(2*dx);
y+=1;
}
x=x+1;
}getch();
 closegraph();
}
close fullscreen
Login or Register to edit or fork this paste. It's free.