C Program to find the Circumference of a Circle – In this specific article, we will brief in on the methods of **finding the circumference of a circle in C Programming**. With the help of this piece, we will explain all the types of ways the circumference of a circle can be calculated. The various ways by which the circumference is calculated in the C program are as follows:

**Using Standard Method****Using Function****Using Pointers****Using Macros**

Circles, as we all know, is the locus of a collection of points which form the boundary and are equidistant from a single point in the middle. The boundary of a circle is known as the Circumference of a circle.

All the points that form the boundary or the circumference of the circle are **equidistant from a single point inside the circle**.

The single point that is present inside the circle is also known as the Center of the circle. The distance from the Center of a circle to any point on the circumference is equal. It is regarded as the **Radius of that very circle**.

If we expand the Radius on the opposite direction and create a line that connects both sides of the circumference while going through the Center, it is known as the Diameter of the circle.

Let us see what all of the above look like in a pictorial form:

As we can see, the four most important aspects of a circle are given in the image uploaded above. Those are as follows:

- Center
- Circumference
- Radius
- Diameter

The radius of a circle is denoted with “r”. The diameter of a circle is denoted with “d”. It is known that the diameter of a circle is double that of the radius.

Mathematically,

d = 2r

Also, the ratio between the circumference and the diameter of a circle is equal to the value of Pi (π). So, we can deduce the formula to calculate the circumference of a circle from this very line.

C/d = π or 22/7

=> C = dπ

=> C = 2πr (since d = 2r)

As we can see, this is the correct formula to find the value of the circumference of any circle. Henceforth, this formula will be used in order to calculate the circumference of a circle in the C programs. The various types of C programs are as follows:

**Using Standard Method**

- The formula for the circumference of a circle is c=(2*22*r)/7.
- The radius value will store into the variable “r”.
- By substituting the “r ” value into the formula we will get circumference value, that value will store into the variable “c”.

1 2 3 4 5 6 7 8 9 10 11 12 |
#include<stdio.h> int main() { float c=1,r; printf("enter radius of the circle: "); scanf("%f",&r); c=(2*22*r)/(7); printf("AOSC: %f\n",c); return 0; } |

**Output:**

1 2 |
enter radius of the circle: 49 AOSC: 308.000000 |

**Using Function**

- Here we using the function float area(int r) to calculate the area of the circumference circle.
- We will call the function using area(r), here we are passing the value of “r”.
- The called function “area(int r)” will calculate the area of the circumference and returns the value, the return value will be assigned to the variable “a”.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include<stdio.h> float area(int r) { return (2*22*r)/(7); } int main() { float a,r; printf("enter radius of the circle: "); scanf("%f",&r); a=area(r); printf("CCOC: %f\n",a); return 0; } |

**Output:**

1 2 |
enter radius of the circle: 7 CCOC: 44.000000 |

**Using Pointers**

- We are calling the function by passing addresses as arguments in area(&r,&c).
- The function void area(float *r, float *a) will calculate the area of the circumference which is having pointer arguments.
- The calculated value will be stored into the variable a.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include<stdio.h> void area(float *r,float *a) { *a=(2*22*(*r))/(7); } int main() { float c=1,r; printf("enter radius: "); scanf("%f",&r); area(&r,&c); printf("CCOC: %f\n",c); return 0; } |

**Output:**

1 2 |
enter radius: 14 CCOC: 88.000000 |

**Using Macros**

- line 2 represents area(r) is a symbolic name for the expression (2*22*r)/7
- area(r)replaced with that expression given at #define.

1 2 3 4 5 6 7 8 9 10 11 12 13 |
#include<stdio.h> #define area(r) (2*22*r)/(7); int main() { float a=1,r; printf("enter radius: "); scanf("%f",&r); a=area(r); printf("CCOC: %f\n",a); return 0; } |

**Output:**

1 2 |
enter radius: 35 CCOC: 220.000000 |