Program to generate polygon.

#include stdio.h
#include conio.h
#include graphics.h

void main()
{
int ax[10],ay[10],i,n,gd,gm=DETECT;
clrscr();
printf("Enter the number of vertices in the polygon\t");
scanf("%d",&n);
printf("\nEnter the co-ordinates of the vertices");
for(i=0;i
{
printf("\nEnter the x cordinate and y cordinate of point %d\t",i+1);
scanf("%d %d",&ax[i],&ay[i]);
}
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
for(i=0;i<(n-1);i++)
{
line(ax[i],ay[i],ax[i+1],ay[i+1]);
}
line(ax[n-1],ay[n-1],ax[0],ay[0]);
getch();
closegraph();
}

No comments:

Post a Comment