answersLogoWhite

0

#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

13y ago

What else can I help you with?

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.


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).


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

reymond rillera reymond rillera


What is the efficiency of the C scan algorithm for disk scheduling?

The efficiency of the C-scan algorithm for disk scheduling is considered to be high. It is a variant of the scan algorithm that improves performance by reducing the seek time of the disk arm. The C-scan algorithm scans the disk in one direction only, which can lead to faster access times compared to other algorithms.


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