Professional Documents
Culture Documents
Branch:UIC Section/Group: B/A
Semester: 5TH Date of Performance:9/30/21
1) Draw a line between the starting point (5, 6) and ending point (8, 12) using DDA Algorithm. Also plot the
intermediate pixels values.
:
#include<graphics.h>
#include<conio.h>
#include<stdio.h>
int main()
float x, y,dx,dy,method;
setbkcolor(WHITE);
dx = (x1 - x0);
dy = (y1 - y0);
if(dx>=dy)
method = dx;
else
method = dy;
dx = dx/method;
dy = dy/method;
x = x0;
y = y0;
i = 1;
while(i<= method)
putpixel(x, y, YELLOW);
x =x+dx;
y = y+dy;
i=i+1;
getch();
closegraph();