1 23203a0061pdf
1 23203a0061pdf
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 :
#include<stdio.h>
#include <graphics.h>
#include <conio.h>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\Turboc3\\BGI");
getch();
closegraph();
Page | 1
return 0;
}
Output:
#include<stdio.h>
#include <graphics.h>
#include <conio.h>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\Turboc3\\BGI");
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");
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:
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:
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\Turboc3\\BGI");
Page | 5
line(250, 200, 300, 250);
line(300, 250, 200, 250);
getch();
closegraph();
return 0;
}
Output:
Page | 6