1.
Write a computer graphics program in C language to draw two dimensional objects like a man,
hut etc.
#include <graphics.h> #include <conio.h>
void main() { int gd = DETECT, gm; initgraph(&gd;, &gm;, "C:\\TURBOC3\\BGI");
rectangle(120, 280, 480, 540); line(120, 280, 300, 160); line(300, 160, 480, 280); rectangle(280,
390, 340, 540); rectangle(170, 360, 240, 430);
circle(620, 250, 35); line(620, 285, 620, 430); line(620, 320, 560, 380); line(620, 320, 680, 380);
line(620, 430, 580, 520); line(620, 430, 660, 520);
getch(); closegraph(); }
3. Write a program in C to draw diagonal lines.
#include <graphics.h> #include <conio.h>
void main() { int gd = DETECT, gm; initgraph(&gd;, &gm;, "C:\\TURBOC3\\BGI");
line(60, 60, 520, 380); line(60, 380, 520, 60);
getch(); closegraph(); }
4. Write program in C to implement built-in Graphics Functions.
#include <graphics.h> #include <conio.h>
void main() { int gd = DETECT, gm; initgraph(&gd;, &gm;, "C:\\TURBOC3\\BGI");
setcolor(GREEN); line(90, 80, 360, 80); rectangle(90, 120, 360, 220); circle(540, 170, 45);
ellipse(540, 320, 0, 360, 90, 50); arc(720, 180, 0, 180, 70); setfillstyle(SOLID_FILL, RED); bar(680,
280, 760, 380);
getch(); closegraph(); }
5. Write a C program for displaying text in different sizes, colors and fonts.
#include <graphics.h> #include <conio.h>
void main() { int gd = DETECT, gm; initgraph(&gd;, &gm;, "C:\\TURBOC3\\BGI");
setcolor(WHITE); settextstyle(DEFAULT_FONT, HORIZ_DIR, 3); outtextxy(120, 90, "Default Font -
Size 3");
setcolor(RED); settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4); outtextxy(120, 170, "Triplex Font -
Size 4");
setcolor(GREEN); settextstyle(SMALL_FONT, HORIZ_DIR, 6); outtextxy(120, 260, "Small Font -
Size 6");
setcolor(BLUE); settextstyle(GOTHIC_FONT, HORIZ_DIR, 5); outtextxy(120, 340, "Gothic Font -
Size 5");
setcolor(YELLOW); settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 4); outtextxy(120, 420, "Sans
Serif Font - Size 4");
getch(); closegraph(); }