# DDA Line Drawing Program in C

## dda_line_drawing_algo.txt

**File size:** 912 Bytes

**File content type:** text/plain

**Category:** Practical Files

**Subject:** Computer Graphics and Multimedia

```
#include<stdio.h>
#include<dos.h>
#include<graphics.h>
#include<math.h>
#include<conio.h>
void lineDDA(int x1, int y1, int x2, int y2) {
int dx,dy,steps,k,x,y,xincrement, yincrement;
dx = x2-x1;
dy = y2-y1;
if(abs(dx)>abs(dy))
steps = abs(dx);
else
steps = abs(dy);
xincrement = dx/steps;
yincrement = dy/steps;
x = x1;
y = y1;
putpixel(x,y,67);
for(k=0;k<steps;k++) {
x += xincrement;
y += yincrement;
putpixel(x,y,67);
delay(20);
}
}
void main() {
int x1,y1,x2,y2;
int gd = DETECT, gm = DETECT;
initgraph(&gd, &gm, "");
printf("Enter the starting coordinates of line:\n");
scanf("%d %d", &x1, &y1);
printf("Enter the ending coordinates of line:\n");
scanf("%d %d", &x2, &y2);
lineDDA(x1, y1, x2, y2);
getch();
}
```

Related searches DDA line drawing algorithm in C, C Program to Draw a Line Using DDA Algorithm

**Last Updated:** July 16, 2022

### Related

#### C program for drawing a Circle using Midpoint Circle Algorithm - CGMT

Category:

**Practical Files**July 16, 2022#### Digital Marketing Notes PDF

Category:

**Notes**July 17, 2022#### P K Sinha Computer Fundamentals Book chapter 11-21

Category:

**eBooks**July 16, 2022#### Exceptions in Java Notes

Category:

**Notes**July 16, 2022#### Marketing Management Notes Unit 1

Category:

**Notes**July 17, 2022#### IPU B.Tech First Year Syllabus

Category:

**Syllabus**July 17, 2022#### Electrical Technology First Sem Akash GGSIPU 2014

Category:

**Question Papers**July 16, 2022#### Nuclear Physics Notes for 1st semester

Category:

**Notes**July 16, 2022#### C program Boundary Value Analysis - Nature of roots of a quadratic equation

Category:

**Practical Files**July 16, 2022#### Data Mining Practical File Exp 1-7

Category:

**Practical Files**July 16, 2022