Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

What is arc() Function in C++? | arc() Example program

 In C++, we can create different objects such as circles, lines, boxes, rectangle and many other shapes using various graphics built-in functions. The arc() function is also a graphic built in function. In this article you will learn about C++ arc() function.


What is arc() Function? 

    The arc() function is used to draw a circular arc starting from a specified angle and up to another special specified angle, along the fixed centered point (x,y) with specified radius. The general syntax of arc() function is as follows:
arc (x,y, stangle, endangle, radius);
All the five parameters are of int type. These may be constants or variables.
In the above syntax:

x & y

It represents the center point of the arc. These are the x-coordinate and y-coordinate of the center of the arc on the screen.

stangle

It represents the starting angle of the arc in degree.

endangle

It represents the ending angle of the arc in degree.

radius

It represents the radius of the arc.

Note: The arc() function can also be used to draw a circle by giving the starting angle 0 (zero) and ending angle 360 degree. Similarly, it can also be used to draw line by giving the same values for starting and ending angles. 

Example of arc() Function

      The following program code draws arcs with different radius, colors, starting angles & ending angles and having the same center point.

#include
#include
main()
{
      int d, m, r, co;
      d = DETECT;      //Auto-detect
      initgraph (&d, &m, " ");
      cleardevice();
      for (co = 1; co       {
         setcolor (co);
         arc (300, 200, 45, 145, co*10);
       }
getch();
cleardevice();
}

Example-2 of arc() Function

      The following program draws circle with different radii & colors and having the same center point by using arc function.

#include
#include
main()
{
      int d, m, r, co;
      d = DETECT;      //Auto-detect
      initgraph (&d, &m, " ");
      cleardevice();
      for (co = 1; co       {
         setcolor (co);
         arc (300, 200, 0, 360, co*10);
       }
getch();
closegraph();
}



This post first appeared on Programming Explain, please read the originial post: here

Share the post

What is arc() Function in C++? | arc() Example program

×

Subscribe to Programming Explain

Get updates delivered right to your inbox!

Thank you for your subscription

×