Thoughts Of The Day



Quote For Sunday, April 6, 2025.

"Our repeated failure to fully act as we would wish must not discourage us. It is the sincere intention that is the essential thing, and this will in time release us from the bondage of habits which at present seem almost insuperable.� Thomas Troward"

CIRCLE

                  Welcome in advance learning tutorial. Today we’ll learn how to draw a circle with the help of graphics in C/C++.

To draw a circle you have to remember two things.
 1)      Center of the circle.
 2)      Radius of the circle.

                  To draw a circle in C/C++ programming first you have to include header file “graphics.h” in your program, and then initialize graphics.

                  In C programming there is a function called “circle” to draw a circle.

Let’s see prototype of the function.

Void circle(int x, int y, int radius);

Here x and y are co-ordinates of center of the circle.

See a program for example -

#include <conio.h>
 #include <graphics.h>

Void main()
{
int gd = DETECT , gm ;
initgraph( &gd, &gm, “ ” );

circle(100,100,50);

getch();
closegraph();

}

                   Attention readers remember one thing - circle function doesn’t return any value.

                  Now if you want to draw another circle inside a circle so just call the circle function two times, but make sure that center of both circles is same and radius of first circle is greater than second circle.

Example

Circle(100,100,50);

Circle(100,100,25);




                  Remember one thing that in circle function all the values you passing are in the form of pixels.
Thank you for reading this article, if you have any doubt or problem in above discussion so asks freely.
                  
                  In the next chapter we will learn how to draw Rectangle in C/C++ using graphics. 




No comments:

Post a Comment


For MNCs Interview Preparation And Practice set of C,C++,JAVA,PHP Questions Like our page.