Draw Shapes using C Graphics

By using Graphics we can draw the geometric figures like circle, line, ellipse, bar etc.

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







   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 )");


   closegraph();//closes the graphics

   return 0;


shapes in c


This c graphics program we draws basic shapes(geometric) like circle, line, rectangle, ellipse and display text on screen . This can be a first graphics program for a beginner.circle() is used to draw the circle,bar() is used to draw the bar on the screen, line() is used to draw the line on the screen, ellipse() is used to draw the ellipse on the screen,outtextxy() is used to display text(“C Graphics Program(rectangle,circle,bar,line,ellipse)")

About Us

Rekha SetiaRekha Setia is a passionate blogger of Extra Computer Notes. if you have any ideas or any request me @