You are on page 1of 6

Practical no.

Part – a

Aim. Write a program in c++ to study and enlist the basic function used for graphics

Part a:

Write a program in C++ to display the point on the screen

#include<iostream>

#include<conio.h>

#include<graphics.h>

void main ()

int gd,gm;

detectgraph(&gd,&gm);

initgraph(&gd,&gm,"C:\TC\BGI");

putpixel(300,300,RED);

//putpixel(300,300,Red);

getch();

}
Write a program in c++ to display a line on the screen

#include<iostream>

#include<conio.h>

#include<graphics.h>

void main()

int gd,gm;

detectgraph(&gd,&gm);

initgraph(&gd,&gm,"C:\TC\BGI");

line(100,100,500,500);

//line(x1,y1,x2,y2);

getch();

Write a program in C++ to display the circle on the screen

#include<iostream>

#include<conio.h>

#include<graphics.h>

void main()

int gd,gm;

detectgraph(&gd,&gm);

initgraph(&gd,&gm,"C:\TC\BGI");

circle(200,200,100);

/circle(x,y,r);
getch();

Write a program in c++ to display rectangle on the screen

#include<iostream>

#include<conio.h>

#include<graphics.h>

void main()

int gd,gm;

detectgraph(&gd,&gm);

initgraph(&gd,&gm,"C:\TC\BGI");

rectangle(200,200,300,300);

//rectangle(x1,y1,x2,y2);

getch();

}
Write a program in c++ to demonstrate the use of setcolor function

#include<iostream>

#include<conio.h>

#include<graphics.h>

void main()

int gd,gm;

detectgraph(&gd,&gm);

initgraph(&gd,&gm,"C:\TC\BGI");

setcolor (RED)

rectangle (200,200,300,300);

//rectangle(x1,y1,x2,y2);

Setcolor (YELLOW);

Circle (250,250,100);

getch();

Write a program in C++ to change the background color of object

#include<iostream>

#include<conio.h>

#include<graphics.h>

void main()

int gd,gm;

detectgraph(&gd,&gm);

initgraph(&gd,&gm,"C:\TC\BGI");

setbkcolor(RED)
rectangle (200,200,300,300);

//rectangle(x1,y1,x2,y2);

Setbkcolor (YELLOW);

Circle (250,250,100);

getch();

Write a program in c++ to display the coordinate axis at the centre of the

#include<iostream>

#include<conio.h>

#include<graphics.h>

void main()

int gd,gm;

detectgraph(&gd,&gm);

initgraph(&gd,&gm,"C:\TC\BGI");

int a= getmaxx();

int b= getmaxy();

line(0,b/2,a,b/2);

line(a/2,0,a/2,b);

getch();

}
Write a program in c++ to

You might also like