Basic Figures Programe Using Graphics 


                                                                        Download File

 

Basic figure draw in C language are:

  • Bar
  • Circle
  • Ellipse
  • Line
  • Rectangle

 Function used to draw different shapes :

  • rectangle(left,top,right,bottom)
  • circle(x,y,radius)
  • bar(left+300,top,right+300,bottom)
  • line(left-10,top+150,left+410,top+150)
  • ellipse(x,y+200,0,360,100,50)
To draw different shapes different functios is used.

How to run this code:

  1. Open your compiler 
  2. Copy the code given below of download the file.
  3. Paste the code on the terminal of your compiler.
  4. Before  debug the code must check the graphics header file is inclue or install in the your compiler , if not install graphics driver in your compiler.
  5. Now run your programe 


#include<graphics.h>

#include<conio.h>

main()

{

   int gd = DETECT,gm,left=100,top=100,right=200,bottom=200,x= 300,y=150,radius=50;

 

    initgraph(&gd, &gm, "C:\\TC\\BGI");

 

    rectangle(left, top, right, bottom);

   circle(x, y, radius);

   bar(left + 300, top, right + 300, bottom);

   line(left - 10, top + 150, left + 410, top + 150);

   ellipse(x, y + 200, 0, 360, 100, 50);

    outtextxy(left + 100, top + 325, "My first C graphics program");

 

   getch();

   closegraph();

   return 0;

}

Post a Comment

Previous Post Next Post