0% found this document useful (0 votes)
3 views2 pages

Computer Graphics-Basics2

The document contains a C program for drawing a line using the graphics library. It prompts the user for starting and ending coordinates and implements the Bresenham's line algorithm to plot the line on the screen. There are some syntax errors and missing elements in the code that need to be corrected for proper execution.

Uploaded by

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

Computer Graphics-Basics2

The document contains a C program for drawing a line using the graphics library. It prompts the user for starting and ending coordinates and implements the Bresenham's line algorithm to plot the line on the screen. There are some syntax errors and missing elements in the code that need to be corrected for proper execution.

Uploaded by

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

Name: Saad Haji Enrollment no: 23111590411 Class : C03KB

Batch: 1 Subject: CGR Practical: 3


Program :
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
#include<dos.h>
void main(){
int x,y,x1,y1,x2,y2,p,i;
int dx, dy;
int gd = DETECT, gm;
clrscr();
printf("\n Enter the value for starting point of line: "); scanf("%d%d", &x1, &y1);
printf("\n Enter the value for ending point: "); scanf("%d%d",&x2,y2);
dx = abs (x2 x1);
dy = abs (y2 - y1);
x = x1;
y = y1;
i = 0;
= 2 * (dy dx);
initgraph (&gd, & gm, "C:\\TURBOC3\/BGI");
while (i<=dx){
putpixel(x,y,WHITE);
if (p<=0){
x = x + 1;
p = p + 2 dy;
}
else{
x = x + 1;
y = y + 1;
p = p + 2 dy
}
i++;
delay(25);
initgraph (&g, & gm, "C:\\TURBOC3\\BGI");
while (i<=dx){
putpixel(x,y,WHITE);
if (p<=0){
x = x + 1;
p = p + 2 dy;
}
else{
x = x + 1;
y = y + 1;
p = p + 2 dy - 2 * dx;
}
i++;
delay(25);
}
getch();
closegraph();
}
Output :

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy