Sector() Function

sector() function is used to draw and fill an elliptical pieslice. sector() is very similar to ellipse() but can fill with any color and / or style set by setfillstyle() function.


void sector( int x, int y, int stangle, int endangle, int xradius, int yradius);
  • sector() function contains six parameters x, y, stangle, endangle, xradius and yradius.
  • x and y specifies the x and y coordinates and (x,y) specifies the center of the sector.
  • stangle and endangle specifies start angle and end angle of the sector. To draw an ellipse from sector() function stangle must be 0 and endangle must be 360.
  • xradius specifies x-radius of the sector and yradius specifies y-radius of the sector.
  • For better understanding go through the program:





void main()


int gd=DETECT,gm;

initgraph(&gd,&gm," ");





Above program is used to draw a sector of x-radius 100 cm and y-radius 50 cm with start angle 0 and end angle 180 degree at position (320,240). The sector would be filled with the white color because white color is default color. We can also draw filled ellipse with the help of sector() function by putting start angle 0 and end angle 360 degree.


c graphics