**C program to calculate area and perimeter of a circle** has been given below. Suppose, the radius of a circle is *r* unit, the area and perimeter of that circle would be (*pi* * *r^2*) unit^2 and (2 * *pi* * *r*) unit, respectively. The approximate value of *pi* is 3.141592.

For example, if the radius of a circle is 5 cm, then area of the circle would be (*pi* * 5^2) = 78.54 cm^2 while perimeter would be (2 * *pi* * *r*) = 31.42 cm.

The algorithm, pseudocode, and time-complexity of the program have also been covered below.

## 1. Algorithm to calculate area and perimeter of a circle

1. Take the radius *r* of a circle as input.

2. Compute *a = pi * r^2*

3. Compute *p = 2 * pi * r*

4. Declare *a* as the area and *p* as the perimeter of that circle.

## 2. Pseudocode to calculate area and perimeter of a circle

**Input** : Radius *r* of a circle

**Output** : Area *A*, Perimeter *P* of the circle

1. **Procedure** areaPerimeter(*r*):

2. *A := pi * r^2*

3. *P := 2 * pi * r*

4. **Return** *A, P*

5. **End Procedure**

## 3. Time complexity to calculate area and perimeter of a circle

**Time Complexity: O(1)**

## 4. C Program & Output to calculate area and perimeter of a circle

/***************************** alphabetacoder.com C program to calculate area and perimeter of a rectangle ******************************/ #include <stdio.h> #define pi 3.141592 int main() { // declare variables float r, a, p; // take input printf("Enter the radius of a circle: "); scanf("%f", & r); // calculate area a = pi * r * r; // calculate perimeter p = 2 * pi * r; // display result upto 3 decimal places printf("Area: %0.3f\n", a); printf("Perimeter: %0.3f\n", p); return 0; }

Output

Enter the radius of a circle: 6

Area: 113.097

Perimeter: 37.699