Basic Shapes
arc() in graphics.h
arc() draws part of a circle between two angles. It is useful for gauges, dial visuals, and curved design elements.
On This Page
Syntax
void arc(int x, int y, int stangle, int endangle, int radius);
Draws an arc centered at (x, y) from start angle to end angle.
Parameters
x, y: center pointstangle: start angle in degreesendangle: end angle in degreesradius: arc radius
arc(250, 220, 0, 180, 120);
This draws a semicircle-like arc. Angle interpretation depends on graphics coordinate orientation.
Full Program
#include <graphics.h>
#include <conio.h>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
arc(250, 220, 0, 180, 120);
arc(250, 220, 180, 360, 90);
arc(250, 220, 45, 135, 60);
getch();
closegraph();
return 0;
}
Common Mistakes
- Swapping start and end angles unexpectedly.
- Using very large radii that exceed screen area.
- Expecting arc to draw a closed shape (it draws only curved segment).
Next: ellipse() and pieslice().