The program allows the user to input the coordinates of a triangle. It then draws the triangle on a graph. The user can select to reflect the triangle across the x-axis, y-axis, or line y=x. Based on the selection, the program performs the mathematical operations to reflect the triangle and redraws it.
1. Program to reflect a triangle
#include<graphics.h>
#include<math.h>
#include<conio.h>
#include<stdio.h>
void main()
{
intgd=DETECT,gm;
int i,xmid,ymid,x1,y1,x2,y2,x3,y3,x,y,dy,dx,p,gap=50,temp,option;
int x1dash,x2dash,x3dash,y1dash,y2dash,y3dash;
double theta;
float m;
char str[5];
clrscr();
initgraph(&gd,&gm,"C:turboc3bgi");
printf("Enter first co-ords of the trianglen");
scanf("%d %d",&x1,&y1);
printf("Enter second co-ords of the trianglen");
scanf("%d %d",&x2,&y2);
printf("Enter third co-ords of the trianglen");
scanf("%d %d",&x3,&y3);
xmid= getmaxx()/2;
ymid= getmaxy()/2;
line(5,ymid,getmaxx()-5,ymid);