You are on page 1of 6

MST -1 PRACTICAL

Student Name: Mohit Singh                                                               UID:19BCA1160

Branch:UIC                                                                           Section/Group: B/A

Semester: 5TH                                                                      Date of Performance:9/30/21

Subject Name :Compute graphic lab                                                                

1) Draw a line between the starting point (5, 6) and ending point (8, 12) using DDA Algorithm. Also plot the
intermediate pixels values.

: SOLUTION OF GIVEN QUESTION :


CODE OF GIVEN QUESTION

:
#include<graphics.h>

#include<conio.h>

#include<stdio.h>

int main()

{ int gd = DETECT ,gm, i;

initgraph(&gd, &gm, (char*)"");

float x, y,dx,dy,method;

int x0, x1, y0, y1;

setbkcolor(WHITE);

x0 = 10 , y0 = 20, x1 = 30, y1 = 40;

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();

CODE OUTPUT PREFORM ON DEV C++

You might also like