Showing Page:
1/1
Write a program for drawing line by applying DDA algorithm?
_________________________________________________________________________________
CODE:
#include <graphics.h>
#include <iostream>
#include <math.h>
#include <dos.h>
using namespace std;
int main( )
{
initwindow(800,800);
float x,y,x1,y1,x2,y2,dx,dy,step;
int i;
cout<<"Enter the value of x1 and y1 ";
cin>>x1>>y1;
cout<<"Enter the value of x2 and y2: ";
cin>>x2>>y2;
dx=abs(x2-x1);
dy=abs(y2-y1);
if(dx>=dy)
step=dx;
else
step=dy;
dx=dx/step;
dy=dy/step;
x=x1;
y=y1;
i=1;
while(i<=step)
{
putpixel(x,y,5);
x=x+dx;
y=y+dy;
i=i+1;
delay(100);
}
closegraph();
}

Unformatted Attachment Preview

Write a program for drawing line by applying DDA algorithm? _________________________________________________________________________________ CODE: #include #include #include #include using namespace std; int main( ) { initwindow(800,800); float x,y,x1,y1,x2,y2,dx,dy,step; int i; cout<<"Enter the value of x1 and y1 "; cin>>x1>>y1; cout<<"Enter the value of x2 and y2: "; cin>>x2>>y2; dx=abs(x2-x1); dy=abs(y2-y1); if(dx>=dy) step=dx; else step=dy; dx=dx/step; dy=dy/step; x=x1; y=y1; i=1; while(i<=step) { putpixel(x,y,5); x=x+dx; y=y+dy; i=i+1; delay(100); } closegraph(); } Name: Description: ...
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4