Write a program to find area of circle in C
In this post, you will know different C programs to find the area of the circle. As we all know, the area of the circle is the measure of the space or region enclosed inside the circle. In geometry, the area enclosed by a circle of radius r is πr2. Here is the simple formula for calculating the area of the circle.
Area = pi * r2
C program to calculate the area of circle using radius
Here is the simple C program to calculate the area of a circle using a radius.
#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 = PI * radius * radius;
printf("Area of circle : %0.4f\n", area);
getch();
return 0;
}
Output 1 -
Enter radius of circle
32
Area of circle : 3216.3840
Output 2 -
Enter radius of circle
52
Area of circle : 8493.2637
C program to calculate area of circle using diameter
Diameter is the distance across the circle passing through the center. We can also calculate the area of the circle if we know the diameter. Either, we can divide the diameter by 2 and calculate the area using the above process, like this -
#include <stdio.h>
#include <conio.h>
#define PI 3.141
int main()
{
float diameter, radius, area;
printf("Enter diameter of a circle : ");
scanf("%f", &diameter);
radius = diameter/2;
area = PI * radius * radius;
printf("Area of circle : %0.4f\n", area);
getch();
return 0;
}
Output of the above code -
Enter diameter of a circle : 20
Area of circle : 314.1000
Enter diameter of a circle : 42
Area of circle : 1385.1810
C program to get area Of circle using circumference
The circle's circumference is the distance around the circle. We can easily calculate the area of a circle if we know the circumference using a formula. A= C²⁄ 4π, where C is the circumference. The following C program demonstrates this -
#include <stdio.h>
#include <conio.h>
#define PI 3.141
int main()
{
float circumference, area;
printf("Enter the circumference of a circle: : ");
scanf("%f", &circumference);
area = (circumference * circumference)/(4 * PI);
printf("Area of circle : %0.4f\n", area);
getch();
return 0;
}
Output of the above code -
Enter the circumference of a circle: : 23
Area of circle : 42.1044
Enter the circumference of a circle: : 56
Area of circle : 249.6020
Related Articles
Prime factors of a number in cArmstrong number program in c
Write a program to check leap year in c
C program to find area of rectangle
C program to convert celsius to fahrenheit
Fibonacci series program in C using recursion
C program to find greatest of three numbers
C program for addition of two numbers
C program to calculate compound interest
C program to find the ASCII value of a character
C program to convert Decimal to Octal
C program to convert decimal to binary
Write a C program to calculate Simple Interest
C program to check whether a number is even or odd
C program to reverse a number
C program to check palindrome number
C program to check whether an alphabet is a vowel or consonant
Program to find square root of a number in C
C program to check whether a number is positive or negative