Draws a circle using circle function

Program Description

Draws a cirlce using the inbuilt circle function available in the BGI library.Takes the radius and the centre co-ordinated from the user.

Program
/********************************************************
* 
*   Draws a circle using the inbuilt method in graphics library
*
*  code.cheraus.com
*
********************************************************/
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
int main()
{
  int gd=DETECT;
  int gm;
  clrscr();    //clears the screen in TurboC(available in conio.h header file)

  int x1,y1;  //variables to hold the co-ordinates
  int r;
  

  //taking the line inputs from user
  cout<<"Enter the radius of the circle: ";
  cin>>r;

  //taking co-ordinates of the centre of the circle
  cout<<"Enter the x co-ordinate of centre: ";
  cin>>x1;
  cout<<"Enter the y co-ordinate of centre: ";
  cin>>y1;

 /*
    initialization of graphics mode. The third argument takes the path
    of the graphics driver in your computer. If you have it in some other
    directory then specify the appropriate path;otherwise it may not work.
  */
  initgraph(&gd,&gm,"C:\\turboc3\\bgi");

 // clears the screen in graphics mode
  cleardevice();

  //function to draw circle
  circle(x1,y1,r);

  //gets a character from the user before exiting the program
  getch();

  //closes the graphics mode
  closegraph();

  //return from main function. Indicates successful run
  return 0;
}

Output
Output Image of Getting Data From User



Final Output

Comments
comments powered by Disqus