0% found this document useful (0 votes)
8 views1 page

Aziz9 CPP

The document is a C program that uses graphics to create and display a polygon based on user-defined coordinates. It allows for the reflection of the polygon across the X-axis and displays both the original and reflected shapes. The program uses Turbo C graphics library functions to initialize the graphics mode and draw lines representing the polygon and its reflection.

Uploaded by

coder2841
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Aziz9 CPP

The document is a C program that uses graphics to create and display a polygon based on user-defined coordinates. It allows for the reflection of the polygon across the X-axis and displays both the original and reflected shapes. The program uses Turbo C graphics library functions to initialize the graphics mode and draw lines representing the polygon and its reflection.

Uploaded by

coder2841
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <stdio.

h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#define ROUND(a)((int )a+0.5)
int main()
{
int n,i,gd=DETECT,gm;
int x[10],y[10];
int xdash[10],ydash[10];
printf("\n enter the no of edges of polygon ");
scanf("%D",&n);
printf("\n enter the cordinates of polygon\n");
for(i=0;i<n;i++)
{
printf("x%d y%d",i,i);
scanf("%d %d",&x[i],&y[i]);

}
x[n]=x[0];
y[n]=y[0];
initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
line(0,240,640,240);
line(320,0,320,480);
outtextxy(550,460,"I");

outtextxy(550,10,"IV");
outtextxy(10,20,"III");
outtextxy(10,460,"II");
for(i=0;i<n;i++)
{

line(320+x[i],240+y[i],320+x[i+1],240+y[i+1]);
}
getch();
outtextxy(10,10,"Reflection about X-axis");
for(i=0;i<n;i++)
{
xdash[i]=x[i];
ydash[i]=-y[i];
}
xdash[n]=xdash[0];
ydash[n]=ydash[0];
for(i=0;i<n;i++)
{
line(320+xdash[i],240+ydash[i],320+xdash[i+1],240+ydash[i+1]);
}
getch();
closegraph();
}

You might also like