Professional Documents
Culture Documents
Graphic 31 08
Graphic 31 08
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
int gd=DETECT,gm;
int a,b,c,d;
initgraph (&gd,&gm,"c:\\tc\\bgi");
scanf("%d%d%d%d",&a,&b,&c,&d);
line(a,b,c,d);
scanf("%d%d%d",&a,&b,&c);
circle(a,b,c);
getch();
closegraph();
OUTPUT:
Enter the coordinate for a line60
30
100
30
1
SUNNY 81005218115
150
80
2
SUNNY 81005218115
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
int gd=DETECT,gm;
int a,b,c,d;
initgraph (&gd,&gm,"c:\\tc\\bgi");
scanf("%d%d%d%d",&a,&b,&c,&d);
line(a,b,c,d);
scanf("%d%d%d%d",&a,&b,&c,&d);
line(a,b,c,d);
scanf("%d%d%d%d",&a,&b,&c,&d);
line(a,b,c,d);
getch();
closegraph();
OUTPUT:
Enter the coordinate for a line60
3
SUNNY 81005218115
30
100
30
30
90
20
20
100
30
4
SUNNY 81005218115
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
int graphic_driver=0,graphic_man,x1,y1,x2,y2,Vr,Hr;
initgraph(&graphic_driver,&graphic_man,"");
scanf("%d%d",&x1,&y1);
scanf("%d%d",&Vr,&Hr);
ellipse(x1,y1,0,360,Vr,Hr);
scanf("%d%d",&x1,&y1);
scanf("%d%d",&x2,&y2);
rectangle(x1,y1,x2,y2);
getch();
closegraph();
5
SUNNY 81005218115
OUTPUT:
Enter the coordinate for X and Y to draw an ellipse200
150
40
200
350
250
6
SUNNY 81005218115
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
int error_check,graph_driver=DETECT,graph_mode;
clrscr();
initgraph(&graph_driver,&graph_mode,"");
error_check=graphresult();
if(error_check!=0)
printf("Error=%s",grapherrormsg(error_check));
getch();
OUTPUT:
Error=Device driver file not found(EGAVGA.BGI)
7
SUNNY 81005218115
#include<stdlib.h>
#include<dos.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
for(int i=EMPTY_FILL;i<USER_FILL;i++)
{
setfillstyle(i,2);
setcolor(4);
delay(700);
rectangle(100,100,200,200);
floodfill(150,170,4);
}
getch();
closegraph();
}
*****-OUTPUT-*****
8
SUNNY 81005218115
#include<stdlib.h>
#include<dos.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
while(!kbhit())
{
setcolor(random(getmaxcolor()));
circle(random(500),random(400),random(90));
delay(200);
}
getch();
closegraph();
}
*****-OUTPUT-*****
9
SUNNY 81005218115
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
float x1,y1,x2,y2,dx,dy,steps,i;
float xinc,yinc;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
scanf("%f %f %f %f",&x1,&y1,&x2,&y2);
dx=x2-x1;
dy=y2-y1;
x=x1;
y=y1;
if(abs(dx)>abs(dy))
steps=dx;
else
steps=dy;
10
SUNNY 81005218115
xinc=dx/steps;
yinc=dy/setps;
for(i=0;i<steps;i++)
putpixel(x,y,4);
x=x+xinc;
y=y+yinc;
getch();
***************OUTPUT****************
11
SUNNY 81005218115
while(x<x2)
{
if(p<0)
p=p+2*dy;
else
{
p=p+2*dy-2*dx;
y++;
}
x++;
putpixel(x,y,i);
}
delay(500);
i++;
}
getch();
closegraph();
}
12
SUNNY 81005218115
********************OUTPUT*******************
13