Basic Shapes
circle() in graphics.h
The circle() function draws a circle using a center point and radius. It is commonly used in beginner graphics programs and animations.
On This Page
Syntax
void circle(int x, int y, int radius);
Draws a circle centered at (x, y) with given radius.
Parameters
x, y: center coordinatesradius: circle radius in pixels
circle(200, 200, 100);
This draws a circle centered at (200, 200) with radius 100.
Using different radius values with the same center is a simple way to create target-like patterns, ripples, and layered designs.
Full Program
#include <graphics.h>
#include <conio.h>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
circle(250, 200, 80);
circle(250, 200, 120);
getch();
closegraph();
return 0;
}
Common Mistakes
- Using negative radius values.
- Placing center too close to edges so circle gets clipped.
- Forgetting
initgraph()orclosegraph().
Next: continue with rectangle() and bar().