-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdda.cpp
More file actions
39 lines (39 loc) · 802 Bytes
/
Copy pathdda.cpp
File metadata and controls
39 lines (39 loc) · 802 Bytes
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
#include<graphics.h>
#include<conio.h>
#include<stdio.h>
int main()
{
int gd = DETECT ,gm, i;
float x, y,dx,dy,steps;
int x0, x1, y0, y1;
// initgraph function initializes the graphics system by loading a graphics driver from disk
// make sure to change the path according to your system.
initgraph(&gd, &gm, "C:\\TC\\BGI");
setbkcolor(WHITE);
x0 = 4 , y0 = 200, x1 = 500, y1 = 5;
dx = (float)(x1 - x0);
dy = (float)(y1 - y0);
if(dx>=dy)
{
steps = dx;
}
else
{
steps = dy;
}
dx = dx/steps;
dy = dy/steps;
x = x0;
y = y0;
i = 1;
while(i<= steps)
{
putpixel(x, y, WHITE);
x += dx;
y += dy;
i=i+1;
}
getch();
closegraph();
return 0;
}