C Program to Draw a Triangle using Graphics
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> main() { int gd, gm, a; gd=DETECT; initgraph(&gd, &gm, "C:\\TC\\BGI"); printf("Enter the value of side of equilateral triangle: "); scanf("%d", &a); setcolor(BROWN); moveto(150, 250); linerel(a,0); linerel(-a/2, -sqrt(3.0)/2*a); lineto(150, 250); outtextxy(20, 450, "Press any key to continue..."); getch(); closegraph(); }
Output: