You are here

Area of a circle in C

Area of Circle

C program to find the area of a circle: C programming code to calculate the area of a circle. In the program, we use 3.14159 as the value of Pi (ϖ). To compute it, we need to know the radius. If we know the diameter or circumference, we find the radius from it. Let's write the program now.

Area of a circle program in C

#include <stdio.h>
#include <math.h>

int main()
{
  float radius, area;

  printf("Enter the radius of a circle\n");

  scanf("%f", &radius);

  area = 3.14159*radius*radius;

  printf("Area of the circle = %.2f\n", area);  // printing upto two decimal places

  return 0;
}

Output of program:
Area of circle C program output

Function to calculate area of a circle

double areaOfCircle(double radius) {
  return 3.14159265358979323846*radius*radius;
}