How to draw a circle in c/c++ ?

To understand the graphics program you must need to understand the simple math behind graphics programming.

To draw a circle in c/c++ we use graphics.h header file, circle( ) and some graphic driver codes to initialize the graphic mode.















Here in this source code, you can see circle( ), there are three arguments are present within circle( ).
so here now you have to pass three arguments within circle( ).

circle(300,250,50);

to understand circle( ) and arguments of circle( ),we will consider the circle( ) like this.

void circle(int x,int y,int r); or circle(x,y,r); 

Here you can see there are three arguments are present within the circle( ). These arguments are the coordinates and radius of the circle function. First, two arguments x=300 and y=250 make a point and centre of the circle, and last argument r=50 is a radius, through which the circle will form.



One another simple way to predict about the coordinates and arguments are.

x=300 is the distance from the left side of the computer screen (horizontally increases).

y=250 is the distance from the top of the computer screen (vertically increases, in the downward direction).

r=50 is the radius of the circle.

#include<stdio.h>
#include<graphics.h>
#include<conio.h>
void main( )
{
clrcsr( );
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
circle(300,250,50);
getch( );
closegraph( );
}











Comments

Popular posts from this blog

Graphics with c/c++