C program to calculate area of circle

In this article, we will illustrate c program to calculate area of circle. The formula for the area of the circle is :

Area_circle = Π * r * r

where,

mathematical value of Π is 3.14159.

Please go through following articles of c programming, if you do not already know about these topics :

simple c program to calculate area of circle

#include <stdio.h>
 
int main() {
   float radius, area_circle;
 
   // take radius as input
   printf("Enter the radius of circle : ");
   scanf("%f", &radius);
 
   area_circle = 3.14 * radius * radius;
   printf("Area of circle : %f", area_circle);
 
   return 0;
}

Output

Enter the radius of circle : 10.0
Area of circle : 314

In this program first, a user is asked to enter the value of the radius of the circle. After that area is calculated and then displayed.

[adsense1]

C program for calculating area of a circle using function

#include <stdio.h>

  //Function declaration
  float areaOfcircle(float radius_circle);

  int main() {
    float radius;

    // take radius as input
    printf("Enter the radius of circle : ");
    scanf("%f", &radius);

    printf("Area of circle : %.2f", areaOfcircle(radius));
    printf("\n");

   return 0;
}

// function definition to calculate area of circle
float areaOfcircle(float radius_circle){
   float area_circle;
   area_circle = 3.14 * radius_circle * radius_circle;

   return area_circle;
}

Output

Enter the radius of circle : 10.0
Area of circle : 314.00

This program also calculates and display the area of the circle but only difference is a function name areaOfcirlce() is used to calculate area of circle and return it.