#include<stdio.h>

#include<conio.h>

#include<math.h>

#include<graphics.h>

void main()

{

int gd=DETECT,gm;

int x1,x2,y1,y2,dx,dy,steps,k;

float xi,yi,x,y;

clrscr();

initgraph (&gd,&gm,"C:\\TC\\BGI");

printf("Enter the co-ordinates of the first point \n");

printf("x1= ");

scanf("%d/n",&x1);

printf("y1= ");

scanf("%d/n",&y1);

printf("Enter the co-ordinates of the second point \n");

printf("x2= ");

scanf("%d/n",&x2);

printf("y2= ");

scanf("%d/n",&y2);

clrscr();

dx= x2-x1;

dy= y2-y1;

if (abs(dx) > abs(dy))

steps = abs(dx);

else

steps = abs(dy);

xi=(float)dx/steps;

yi=(float)dy/steps;

x=x1;

y=y1;

for(k=0;k<steps;k++)

{

putpixel (x,y,BLUE);

x=x+xi;

y=y+yi;

}

getch();

closegraph();

}

## Saturday, May 2, 2009

### C program to implement Digital Differential Analyzer Line drawing algorithm

Labels: Digital Differential Analyzer Line drawing algorithm

Posted by Angad at 3:06 PM

Subscribe to:
Post Comments (Atom)

## 7 comments:

thank you so much!!!

it helped a lotttttt!!!

thanks a lot..................

it improved my programming logic

it is not working when both the points are having the same y value.that is when y1 and y2 are same.for eg:(300,120) and (180,120).please help me out with this.

take points (-5,-10)

Naming Distributed system

Conversion from NFA to DFA (Thompson’s rule)

virtual mode 80386

time shared common bus

mapping cardinality

rsa algorithm

general pivot

steepest ascent hill climbing

page replacement strategies

Direct View Storage Tubes

Block Diagram of 8259A

Block Diagram of Programmable Peripheral Interface

Relocation of Linking Concept

Character Generation

Different Loading Schemes

Block Structure and Non Block Structure Storage Allocation

Inside Outside Tests

Counters and Time Delays

SAP BW on HANA Tutorial

SAP BW Tutorial

SAP BO Analysis Edition For OLAP Tutorial

SAP BPC Tutorial

Ethical Hacking Tutorial

Ethical Hacking & Cyber Security

Cyber Crime & Cyber Security

Post a Comment