Digital Differential Analyzer (DDA) is a scan-conversion line drawing algorithm based on calculating either dx or dy using equation dy=mdx. Sampling line at unit intervals in one coordinate and determining corresponding integer values nearest the line path is done for other coordinate.
For a line of positive slope value less than or equal to 1, sampling is done at unit x intervals (dx=1) and corresponding y is calculated as yk+1=yk+m. Similarly, in case of slope greater than 1, dy=1 is kept sampling at unity intervals whereas each succeeding x value is calculated as: xk+1 = xk + 1/m.
int gdriver=DETECT, gmode, errorcode;
printf(“Enter the value of x1, y1, x2 and y2 : “);
scanf(“%f %f %f %f”,&x1, &y1, &x2, &y2);