Mographic Notes
Mographic Notes
SESSION 2022-2023
PRACTICAL FILE
SUBMITTED BY:
SUBMITTED TO:
INDEX
S.NO PROGRAMS REMARKS
}
Output
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
printf(" ------pentagon------- ");
line(200,400,500,400);
line(200,400,150,250);
line(150,250,350,100);
line(350,100,550,250);
line(550,250,500,400);
getch();
closegraph();
}
Output:
circle(200,200,20);
line(100,200,100,400);
line(300,200,300,400);
line(100,250,300,250);
line(100,400,300,400);
line(200,150,500,150);
line(500,150,600,200);
line(300,200,600,200);
line(600,200,600,400);
line(300,400,600,400);
line(150,400,150,300);
circle(200,320,15);
line(200,335,200,370);
line(200,345,175,360);
line(200,345,225,360);
line(200,370,175,400);
line(200,370,225,400);
line(150,300,250,300);
line(250,300,250,400);
line(400,250,500,250);
line(400,250,400,330);
line(400,330,500,330);
line(500,250,500,330);
line(450,250,450,330);
line(400,290,500,290);
circle(560,70,50);
getch();
closegraph();
}
Output:
line(50+x,340,50+x,370);
//car window
line(165+x,305,165+x,330);
line(165+x,330,230+x,330);
line(230+x,330,195+x,305);
line(195+x,305,165+x,305);
line(160+x,305,160+x,330);
line(160+x,330,95+x,330);
line(95+x,330,120+x,305);
line(120+x,305,160+x,305);
//wheel
circle(110+x,370,17);
circle(240+x,370,17);
setfillstyle(SOLID_FILL,BLUE);
floodfill(201+x,310,WHITE);
setfillstyle(SOLID_FILL,BLUE);
floodfill(121+x,315,WHITE);
delay(10);
cleardevice();
}
getch();
}
Output:
//driver code
int main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TC\\bgi");
// circle function
printf("----------------draw circle------------");
circle(150, 100, 50);
getch();
closegraph();
}
Output:
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());
/* clean up */
getch();
closegraph();
return 0;
}
Output:
Output:
// driver code
int main()
{
int gd = DETECT, gm;
// initial coordinate to
// draw line
int x = 200, y = 100;
// Drawing line
line(x, y, x+200, y);
y = y + 25;
BCA 2RD YEAR
~ 14 ~
}
getch();
closegraph();
return 0;
}
Output:
int main()
{
int start_angle = 0;
int end_angle = 360;
ellipse(x, y, start_angle,
getch();
return 0;
}
Output:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd,gm;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
line(200,200,300,100);
line(200,200,300,300);
line(300,100,400,200);
line(400,200,300,300);
line(300,100,300,300);
arc(300,300,45,135,140);
setfillstyle(SOLID_FILL,BLUE);
floodfill(301,105,WHITE);
setfillstyle(SOLID_FILL,LIGHTRED);
floodfill(299,105,WHITE);
setfillstyle(SOLID_FILL,BLUE);
floodfill(299,275,WHITE);
setfillstyle(SOLID_FILL,LIGHTRED);
floodfill(301,275,WHITE);
line(300,300,250,350);
line(250,350,350,350);
line(300,300,350,350);
setfillstyle(SOLID_FILL,YELLOW);
floodfill(300,310,WHITE);
getch();
closegraph();
}
Output:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd,gm;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"C:\\TC\\BGI");
printf(" --------------draw fish---------------");
ellipse(200,200,0,360,130,50);
setfillstyle(LINE_FILL,CYAN);
floodfill(201,201,15);
line(325,185,390,155);
line(390,155,360,200);
line(395,235,325,215);
line(395,235,360,200);
setfillstyle(LINE_FILL,LIGHTRED);
floodfill(330,190,15);
ellipse(100,200,315,45,50,60);
circle(120,180,3);
setfillstyle(SOLID_FILL,YELLOW);
floodfill(120,180,3);
line(170,150,260,90);
line(260,90,220,150);
setfillstyle(LINE_FILL,LIGHTRED);
floodfill(200,140,15);
line(170,250,260,290);
line(260,290,230,250);
setfillstyle(LINE_FILL,LIGHTRED);
floodfill(200,255,15);
arc(220,185,270,90,6);
arc(200,185,270,90,6);
arc(180,185,270,90,6);
arc(200,215,270,90,6);
arc(220,215,270,90,6);
arc(180,215,270,90,6);
arc(240,200,270,90,6);
getch();
closegraph();
}
Output:
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <stdlib.h>
int main() /* Main function begins */
{
/* Declare the graphic variables */
int gdriver, gmode, userpattern;
int x, y, x_max, y_max;
/* Initialize the graphics driver to autodetect the graphics drivers */
gdriver = DETECT;
userpattern = 1;
/* Initialization of graph and path set to graphics interface */
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
/* Set the line style */
setlinestyle(DOTTED_LINE,userpattern, 3);
/* Draw the line */
x = 100;
y = 70;
x_max = 350;
y_max = 70;
line(x, y, x_max, y_max);
/* close the graph */
getch();
closegraph();
return 0;
}
Output:
#include <graphics.h>
#include <stdio.h>
#include <math.h>
#include <dos.h>
void main( )
{
float x,y,x1,y1,x2,y2,dx,dy,step;
int i,gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
dx=abs(x2-x1);
dy=abs(y2-y1);
if(dx>=dy)
step=dx;
else
step=dy;
dx=dx/step;
dy=dy/step;
x=x1;
y=y1;
i=1;
while(i<=step)
{
putpixel(x,y,5);
x=x+dx;
y=y+dy;
i=i+1;
delay(100);
}
closegraph();
}
Output:
}
else
{
putpixel(x,y,7);
p=p+2*dy;}
x=x+1;
}
}
int main()
{
int gdriver=DETECT, gmode, error, x0, y0, x1, y1;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
printf("Enter co-ordinates of first point: ");
scanf("%d%d", &x0, &y0);
printf("Enter co-ordinates of second point: ");
scanf("%d%d", &x1, &y1);
drawline(x0, y0, x1, y1);
return 0;
}
Output:
struct time t;
void display(int,int,int);
void main()
{
int i=0,gd=DETECT,gm,hr,min,sec;
clrscr();
initgraph(&gd,&gm,"c:\\tc\\bgi");
setcolor(GREEN);
settextstyle(4,0,7);
while(!kbhit())
{
gettime(&t);
hr=t.ti_hour;
min=t.ti_min;
sec=t.ti_sec;
i++;
display(100,100,hr);
display(200,100,min);
display(300,100,sec);
sound(400);
delay(30);
nosound();
delay(930);
cleardevice();
}
getch();
}
void display(int x,int y,int num)
{
char str[3];
itoa(num,str,10);
settextstyle(4,0,7);
outtextxy(180,100,":");
outtextxy(280,100,":");
outtextxy(x,y,str);
rectangle(90,90,380,200);
rectangle(70,70,400,220);
outtextxy(90,250,"Digital Clock");
}
Output:
int main()
{
//initilizing variables
int middlex, middley;
setcolor(WHITE);
rectangle(middlex-30,middley-80,middlex+30,middley+80);
circle(middlex, middley+50, 22);
getch();
return 0;
}
Output:
int gd=DETECT,gm;
int x,y,r,c1;
initgraph(&gd,&gm,"c:\\tc\\bgi");
circle(150,70,70);
circle(120,50,10);
circle(190,50,10);
line(155,60,155,80);
arc(155,100,180,360,20);
line(130,140,130,170);
line(170,140,170,170);
rectangle(80,170,230,260);
line(110,260,110,360);
line(205,260,205,360);
line(80,190,55,240);
line(230,190,255,240);
getch();
closegraph();
}
Output: