0% found this document useful (0 votes)
27 views3 pages

Akhlad Kaifi Brenhsen Algorithm

This document contains a C program that uses graphics to draw a line between two points specified by the user. The program initializes the graphics mode and prompts the user to input the coordinates of the two points. It then calculates the necessary parameters to draw the line using the Bresenham's line algorithm.

Uploaded by

akhlad kaifi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

Akhlad Kaifi Brenhsen Algorithm

This document contains a C program that uses graphics to draw a line between two points specified by the user. The program initializes the graphics mode and prompts the user to input the coordinates of the two points. It then calculates the necessary parameters to draw the line using the Bresenham's line algorithm.

Uploaded by

akhlad kaifi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Name Akhlad kaifi

Roll no. 31

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void drawline(int x0, int y0, int x1, int y1)
{
int dx, dy, p, x, y;
dx=x1-x0;
dy=y1-y0;
x=x0;
y=y0;
p=2*dy-dx;
while(x<x1)
{
if(p>=0)
{
putpixel(x,y,4);
y=y+1;
p=p+2*dy-2*dx;
delay(100);
}
else
{
putpixel(x,y,4);
p=p+2*dy;}
x=x+1;
delay(100);
}
}
int main()
{
int gdriver=DETECT, gmode, error, x0, y0, x1, y1;
initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");
printf("Enter co-ordinates of first point: ");
scanf("%d%d", &x0, &y0);
printf("Enter co-ordinates of second point: ");
scanf("%d%d", &x1, &y1);
drawline(x0, y0, x1, y1);
getch();
return 0;
}

You might also like