answersLogoWhite

0

#include<stdio.h> #include<conio.h> #include<math.h> #include<graphics.h> void draw_line(float,float,float,float); main() { int driver,mode; float x1,y1,x2,y2; clrscr(); printf("Enter the two endpoints of the line:"); printf("\nx1 ="); scanf("%f",&x1); printf("y1 ="); scanf("%f",&y1); printf("x2 ="); scanf("%f",&x2); printf("y2 ="); scanf("%f",&y2); clrscr(); driver = DETECT; initgraph(&driver,&mode,"\\tc\\bgi"); \\path of bgi can be different in your case draw_line(x1,y1,x2,y2); getch(); closegraph(); } void draw_line(float x1,float y1,float x2,float y2) { float dy,dx; float x,y; float p,p0,dp1,dp2; dy = y2-y1; dx = x2-x1; p0 = 2 * (dy - dx); dp1 = 2 * dy; dp2 = 2 * (dy - dx); putpixel(x1,y1,EGA_WHITE); p = p0; for(x=x1+1,y=y1;x<x2;x++) { if(p < 0) { p = p+dp1; putpixel(x,y,EGA_WHITE); } else { p = p+dp2; y++; putpixel(x,y,EGA_WHITE); } }

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

What is the most efficient way to implement a factorial algorithm in a programming language?

The most efficient way to implement a factorial algorithm in a programming language is to use an iterative approach rather than a recursive one. This involves using a loop to multiply the numbers from 1 to the given input number to calculate the factorial. This method is more memory-efficient and faster than using recursion.


Can you provide a solution to the diamond-square algorithm using Java and recursion?

Yes. It is possible to provide a solution to the diamond-square algorithm using Java and recursion.


How do you sinx without using mathh or built in sin function Any Algorithm to implement sin function?

You can compute sin(x) manually/numerically using Taylor's Series.


How do you implement algorithm in layered approach using conditional random field intrusion detection?

if u having this project means mail to aravindramesh11@gmail.com


What is the algorithm for determining the maximum of two numbers?

Compare two numbers, a and b. If a is greater than b then return a, otherwise return b. In C, we can implement this algorithm using the ternary operator (?:), as follows: return a&gt;b?a:b;


What the difference between algorithm and pseudocode?

An algorithm is a description of a method for accomplishing some task. For example, an algorithm for driving to a friend's house could be:1. Find your keys2. Get into the car3. Start the engine4. Put transmission into gearetc...Psuedocode is an implementation of an algorithm in a code-like format. For example, the above algorithm in psuedocode could look something like:while(keys.location != "in your hand"){search_for_keys();}walk_to_car();if(car.door == locked)car.door.unlock();engine.start();...An algorithm describes the steps required to solve a problem. Algorithms are written using natural language (e.g., English).Pseudocode is a human-readable version of an algorithm written using an informal language that is very similar to a programming language but which can be more easily translated into any specific programming language.


How do you run graphics program in C?

pro c language to implement linear search using pointers


What is the difference between implementation and algorithm?

An algorithm is a instruction for solving a problem. It is typically illustrated using prose, pseudo code or flowcharts, but other methods exist. The algorithm is the "here's how it's going to work" part of the solution. An implementation (of an algorithm) is a specific expression of this algorithm, using a specific programming language or any other suitable means. The implementation is the "here's how I've done it" part of the solution.


What is the difference between an algorithm and a program?

An algorithm is a step-by-step procedure for solving a problem, while a program is a set of instructions written in a programming language that implements an algorithm to perform a specific task on a computer. In simpler terms, an algorithm is like a recipe, and a program is like the dish you make using that recipe.


How do you implement svm algorithm in java?

A kernel is used to implement the SVM algorithm in practise. An input data space is transformed into the appropriate form using a kernel. The kernel trick is a technique used by SVM. The kernel transforms a low-dimensional input space into a higher-dimensional space in this case. To learn more about data science please visit- Learnbay.co


How do you RSA algorithm c?

Perform encryption on the following PT using RSA and find the CT p = 3; q = 11; M = 5


What are disadvantage of algorithm?

Advantages of an Algorithm: Effective Communication: Since the algorithm is written in English like language, it is simple to understand the step-by-step solutions of the problems. Easy Debugging: Well-designed algorithm makes debugging easy so that we can identify a logical error in the program. Easy and Efficient Coding: An algorithm acts as a blueprint of a program and helps during program development. Independent of Programming Language: An algorithm is independent of programming languages and can be easily coded using any high-level language. Disadvantages of an Algorithm: Developing algorithms for complex problems would be time-consuming and difficult to understand. Understanding complex logic through algorithms can be very difficult.