29-08-2017, 11:43 AM
Algorithm:
1. Start the program.
2. Initialize the variables.
3. Call the initgraph () function
4. Set the color for the output primitives.
5. Using Outtextxy () displays the custom primitives.
6. Using the switch case, mention the various primitives and their attributes.
7. The various primitives arc, line, circle, rectangle and ellipse.
8. Close the chart and run the program.
9. Stop the program.
PROGRAM:
1. Start the program.
2. Initialize the variables.
3. Call the initgraph () function
4. Set the color for the output primitives.
5. Using Outtextxy () displays the custom primitives.
6. Using the switch case, mention the various primitives and their attributes.
7. The various primitives arc, line, circle, rectangle and ellipse.
8. Close the chart and run the program.
9. Stop the program.
PROGRAM:
Code:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<string.h>
void main()
{
char ch='y';
int gd=DETECT,gm,x1,y1,x2,y2,rad,sa,ea,xrad,yrad,i;
initgraph(&gd,&gm,"");
while(ch=='y')
{
cleardevice();
setbkcolor(9);
outtextxy(100,150,"Enter 1 to get line");
outtextxy(100,170,"2.Circle");
outtextxy(100,190,"3.Box");
outtextxy(100,210,"4.Arc");
outtextxy(100,230,"5.Ellipse");
outtextxy(100,250,"6.Rectangle");
outtextxy(100,270,"7.Exit");
ch=getch();
cleardevice();
switch(ch)
{
case '1':
line(100,200,300,400);
break;
case '2':
circle(200,200,100);
break;
case '3':
setfillstyle(5,4);
bar(100,300,200,100);
break;
case '4':
setfillstyle(5,4);
arc(200,200,100,300,100);
break;
case '5':
setfillstyle(5,4);
fillellipse(100,100,50,100);
break;
case '6':
settextstyle(DEFAULT_FONT,0,2);
outtextxy(120,140,"VEL TECH");
line(100,100,100,300);
line(300,300,100,300);
line(100,100,300,100);
line(300,100,300,300);
break;
case '7':
closegraph();
return;
}
ch='y';
getch();
}
}