0% found this document useful (0 votes)
52 views6 pages

1 23203a0061pdf

Uploaded by

devilblood496
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)
52 views6 pages

1 23203a0061pdf

Uploaded by

devilblood496
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/ 6

DEPARTMENT OF COMPUTER ENGINEERING

Subject: Computer graphics Subject Code:313001

Semester:3rd Semester Course: Computer Engineering

Laboratory No: V120 Name of Subject Teacher: Pradeep Shirke

Name of Student: Chintan Gupte Roll Number: 23203A0061

Experiment No: 1

Title of Experiment Write a C program to draw various graphics objects (Pixel, Circle, Line,
Ellipse, Rectangle, Triangle, Polygon) using graphics functions.

I. Practical Significance:
3D translation and scaling are fundamental in fields like computer graphics and robotics.
They enable realistic object manipulation in simulations and games, facilitate navigation in
robotic systems, and enhance engineering design processes in CAD applications, allowing
for efficient modeling and visualization.

III. C PROGRAM :

1. Program to draw a pixel

#include<stdio.h>
#include <graphics.h>
#include <conio.h>

int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\Turboc3\\BGI");

putpixel(100, 100, WHITE);

getch();
closegraph();

Page | 1
return 0;
}

Output:

2. Program to draw a line

#include<stdio.h>
#include <graphics.h>
#include <conio.h>

int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\Turboc3\\BGI");

line(50, 50, 200, 50);

getch();
closegraph();
return 0;
}

Output:

Page | 2
3. Program to draw a circle
#include<stdio.h>
#include <graphics.h>
#include <conio.h>

int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\Turboc3\\BGI");

circle(300, 150, 50);

getch();
closegraph();
return 0;
}
Output:

Page | 3
4. Program to draw an ellipse
#include<stdio.h>
#include <graphics.h>
#include <conio.h>

int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\Turboc3\\BGI");

// Draw an ellipse with center (400, 150), width 100 and height 50
ellipse(400, 150, 0, 360, 50, 25);

getch();
closegraph();
return 0;
}

Output:

5. Program to draw rectange


#include<stdio.h>
#include <graphics.h>
#include <conio.h>

int main() {
int gd = DETECT, gm;

Page | 4
initgraph(&gd, &gm, "C:\\Turboc3\\BGI");

// Draw a rectangle with top-left corner (50, 200) and bottom-right corner
(150, 300)
rectangle(100, 100, 300, 200);

getch();
closegraph();
return 0;
}

Output:

6. Program to draw a Triangle


#include<stdio.h>
#include <graphics.h>
#include <conio.h>

int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\Turboc3\\BGI");

line(200, 250, 250, 200);

Page | 5
line(250, 200, 300, 250);
line(300, 250, 200, 250);

getch();
closegraph();
return 0;
}

Output:

Grade and Process Related Product Related Dated Sign


Dated
(35) (15)
Signature
of Teacher

Page | 6

You might also like