answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

#include<ctype.h>

#include<math.h>

#include<stdlib.h>

void draw(int x1,int y1,int x2,int y2);

void main()

{

int x1,y1,x2,y2;

int gdriver=DETECT,gmode,gerror;

initgraph(&gdriver,&gmode,"c:\\tc\\bgi:");

printf("\n Enter the x and y value for starting point:\n");

scanf("%d%d",&x1,&y1);

printf("\n Enter the x and y value for ending point:\n");

scanf("%d%d",&x2,&y2);

printf("\n The Line is shown below: \n");

draw(x1,y1,x2,y2);

getch();

}

void draw(int x1,int y1,int x2,int y2)

{

float x,y,xinc,yinc,dx,dy;

int k;

int step;

dx=x2-x1;

dy=y2-y1;

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

step=abs(dx);

else

step=abs(dy);

xinc=dx/step;

yinc=dy/step;

x=x1;

y=y1;

putpixel(x,y,1);

for(k=1;k<=step;k++)

{

x=x+xinc;

y=y+yinc;

putpixel(x,y,2);

}

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Ddl algorithm of line generation in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How can you implement Ricart and Agrawala's algorithm in c?

Ronaldo! 'c' coding of Ricart-agarwala algorithm


How do you write an Algorithm for a C plus plus Program?

You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.


What is algorithm in c?

Algorithm is a step by step process to solve a particular task.


What is an algorithm for multiplying rational numbers?

The algorithm is A/B * C/D = AB/CD.


C code to implement the file allocation algorithm?

yes we can do it,in c


Can you give a C program about SJF algorithm?

no.


Program in c to develop an algorithm that prints the n value of algorithm?

reymond rillera reymond rillera


What is the use of execute non query in c?

It is not C, it's SQL. Non-query means DML (INSERT, UPDATE, DELETE) and DDL (eg CREATE TABLE).


C coding for cooley tukey fft algorithm?

hi.... for DIT fft algorithm, refer to this link, it has c-code for that. http://cnx.org/content/m12016/latest/


How do you write algorith of C programs?

There is no specific Hard and Fast rule for writing algorithm. The normal method is the following: 1. get a problem 2. find or invent an algorithm to solve it 3. implement the algorithm in a programming language (C, for example)


Algorithm of push and pop in c plus plus?

pop push c++ programming


How do you use the longest Prefix Match algorithm in C programming?

You can use the longest Prefix Match algorithm in C programming by looking up the longest standard Python package match and then converting that from Python into C or C++ to figure out how to create the equivalent.