forked from sarthakprajapati/HacktoberFest2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BSNHAMS.CPP
52 lines (44 loc) · 829 Bytes
/
BSNHAMS.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
void drawline(int x0, int y0, int x1, int y1)
{
int dx, dy, p, x, y;
dx=x1-x0;
dy=y1-y0;
x=x0;
y=y0;
p=2*dy-dx;
while(x<x1)
{
if(p>=0)
{
putpixel(x,y,5);
delay(50);
y=y+1;
p=p+2*dy-2*dx;
}
else
{
putpixel(x,y,5);
delay(50);
p=p+2*dy;
}
x=x+1;
}
}
int main()
{
int gdriver=DETECT, gmode, error, x0, y0, x1, y1;
initgraph(&gdriver, &gmode, "C:\\TurboC3\\BGI");
printf("Enter co-ordinates of first point: ");
scanf("%d%d", &x0, &y0);
printf("Enter co-ordinates of second point: ");
scanf("%d%d", &x1, &y1);
drawline(x0, y0, x1, y1);
delay(50);
getch();
closegraph();
return 0;
}