How to draw different shapes in C programming?

Using Graphics, we can draw geometric figures like circles, lines, ellipses, bars, etc.

In this, we set the coordinates like leftt,top, right,bottomm.Graphics.h library is used for graphics (initgraph method).

 

C program to draw shapes using graphics

#include<graphics.h>

#include<conio.h>

main()

{

int gdd = DETECT,gmm,leftt=100,topp=100,rightt=200,bottomm=200,xx= 300,yy=150,radiuss=50;

initgraph(&gdd, &gmm, “C:\\TC\\BGI”);//initialization of graphics

rectangle(leftt, topp, rightt, bottomm);

circle(xx, yy, radiuss);//xx is vertical axis, yy is horizontal axis

bar(leftt + 300, topp, rightt + 300, bottomm);

line(leftt – 10, topp + 150, leftt + 410, topp + 150);

ellipse(xx, yy + 200, 0, 360, 100, 50);//draw ellipse

outtextxy(leftt + 100, topp + 325, ” C Graphics Program (rectangle ,circle, bar, line, ellipse )”);

getch();

closegraph();//closes the graphics

return 0;

}

WHAT IS THE STRUCTURE OF THE C PROGRAM?