Showing posts with label Triangle using C graphics. Show all posts
Showing posts with label Triangle using C graphics. Show all posts

Saturday, October 31

To display a triangle using C Programming!

// to display a triangle using Graphics
#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm,x,a,b;
initgraph (&gd,&gm,"c:\\tc\\bgi ");
while(!kbhit()) //display a triangle till a key is pressed
{
setcolor(WHITE);
line(300,200,400,300);
line(300,200,200,300);
line(200,300,400,300);
}
getch();
}