C Program to Calculate Area and Circumference of a Circle

  • Write a C program to find the area and circumference of a circle.
  • Write a C program to find area of a circle.

A circle is a simple geometrical shape. A circle is a set of all points in a 2D plane that are at a given distance from a given point called centre. A circle can be uniquely identified by it's center co-ordinates and radius.

  • Center of a Circle is a point inside the circle and is at an equal distance from all of the points on its circumference.
  • Radius is the length of the a segment joining the centre of the circle to any point on the circle.
  • Diameter is the length of the a segment passing through centre of the circle and joining two points on edge. Diameter is twice of Radius.
C program to find area of a circle

The area of circle is the amount of two-dimensional space taken up by a circle. The area of a circle can be calculated by placing the circle over a grid and counting the number of squares that circle covers. Different shapes have different ways to find the area.
We can compute the area of a Circle if you know its radius.

Area of Circle = PI X Radius X Radius.
Where PI is a constant which is equal to 22/7 or 3.141(approx)
Area is measured in square units.

Circumference is the linear distance around the edge of a circle. It is the length of the curved line which defines the boundary of a circle. The perimeter of a circle is called the circumference.

We can compute the circumference of a Circle if you know its radius.
  • Circumference or Circle = 2 X PI X Radius
We can also compute the circumference of a Circle if you know its diameter.
  • Circumference or Circle = PI X Diameter

C Program to find the area of the circle

/*
* C Program to calculate area of a circle
*/
#include <stdio.h>
#include <conio.h>

#define PI 3.141

int main(){
    float radius, area;
    printf("Enter radius of circle\n");
    scanf("%f", &radius);
    /* Area of Circle = PI x Radius X Radius */
    area = PI*radius*radius;
    printf("Area of circle : %0.4f\n", area);
    
    getch();
    return 0;
}
In above program, we first take radius of a circle as an input from user using scanf function and store it in floating point variable named "radius". Now, we calculate the area of circle(PI X radius X radius) and store it in variable area. Then we print the area of circle on screen using printf function.

Program Output
Enter radius of circle
5
Area of circle : 78.5250

C Program to find the area of a circle using pow function

We can use pow function of math.h header file to calculate Radius^2(Radius square) instead of multiplying Radius with itself. double pow(double a, double b) returns a raised to the power of b (a^b). Below program uses pow function to calculate the area of circle.

/*
* C Program to calculate area of a circle 
* using pow function
*/
#include <stdio.h>
#include <math.h>
#include <conio.h>

#define PI 3.141

int main(){
    float radius, area;
    printf("Enter radius of circle\n");
    scanf("%f", &radius);
    /* Area of Circle = PI x Radius X Radius */
    area = PI*pow(radius, 2);
    printf("Area of circle : %0.4f\n", area);
    
    getch();
    return 0;
}

Program Output
Enter radius of circle
3
Area of circle : 28.2690

C Program to calculate circumference of the circle

Below program calculates the circumference of a circle by taking radius of circle as input from user. We can also find circumference of a circle from diameter, as diameter of a circle is twice of radius.
Below program first take radius of a circle as input from user and then calculate circumference(perimeter) of a circle as 2 X PI X Radius. It then prints the result on screen using printf function.

/*
* C Program to find circumference of a circle
*/
#include <stdio.h>
#include <conio.h>

#define PI 3.141

int main(){
 float radius, circumference;
 printf("Enter radius of circle\n");
 scanf("%f", &radius);
 /* Circumference of Circle =2 x PI x Radius */
 circumference = 2*PI*radius;
 printf("Circumference of circle : %0.4f\n", circumference);
 
 getch();
 return 0;
}

Program Output
Enter radius of circle
3.0
Circumference of circle : 18.8460

Properties of Circle
  • Diameter is the longest chord of a circle.
  • A triangle inside a semi-circle with diameter as one site is always a right angles triangle.
  • A tangent to a circle is at right angles to the radius at the point of intersection.
  • The length of arc of a circle is proportional to the angle subtended by the arc at the center.
  • The equation of a circle whose center is at (0,0) and radius R is x2 + y2 = R2.

Related Topics

C program to calculate area of a square
C program to calculate area of a rectangle
C program to calculate area of a rhombus
C program to calculate area of an equilateral triangle
C program to calculate area of a right angled triangle
C program to calculate area of a trapezium
C program to calculate volume and total surface area of cone
C program to calculate volume and total surface area of sphere
List of all C Programs