Home / C / Program in C to draw a TRIANGLE

Program in C to draw a TRIANGLE

Here is the program for creating a triangle in C.

#include<conio.h>
#include<stdio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\TC\\bgi");
line(150,100,100,200);
line(100,200,200,200);
line(200,200,150,100);
getch();
closegraph();
}

OUTPUT:

Tags: c program to draw a triangle, graphics program to draw a triangle, create

Check Also

Restrict Mouse Pointer Position C Graphics Program

This C Program will restrict the Mouse Pointer location or to a particular position or x,y ...

2 comments

  1. i need the 2d TRANSFORMATION translation coding only using line(), pls explain it by using this method

  2. Well we can do this thing by passing an array and then using the command drawpoly(1 ,2).
    Where 1 represents no. of sides which should be one more than the shape to be output here in this case 4 as we have to output triangle and 2 represents the name of the array which contain the coordinates of triangle.

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.