Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Chandigarh Univerity CG-LAB

EXPERIMENT-2

To Display Simple Shapes like Hut etc. using Graphic Primitives.

ALGORITHM:
1. Initialise graphics header file in your program .
2. Initialise graphics mode and graphics driver .
3. under initgraph function pass 3 parameters consisting of graphics mode , drivers and
path for borland graphics interpreter.
4. use line , circle commands with proper x,y coordinates and specifying radius of
circle.
5. use outtextxy function to write any text at given coordinates.
6. in the end do not forget to use closegraph function.
CODE:

#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\turboC3\\BGI");
line(100,100,300,100);
line(100,100,125,45);
line(125,45,150,100);
line(125,45,280,45);
line(300,100,280,45);
line(100,100,100,200);
line(150,100,150,200);
line(300,100,300,200);
line(100,200,300,200);
circle(125,70,9);
line(175,45,200,100);
line(225,45,250,100);
outtextxy(225,150,"HUT");

15BCS1423
Chandigarh Univerity CG-LAB

getch();
closegraph();
}

Output:

TIME COMPLEXITY:
As this code does not involve any loops or iteration , therefore it will take
constant time "C" to execute.

15BCS1423

You might also like