Diameter, Area & Circumference of Circle
C Program to find Diameter, Circumference, and Area Of a Circle
In this article, we will show you, How to write a C Program to find Diameter, Circumference, and Area Of a Circle using Functions with example.
The mathematical formulas behind these calculations are:
- Diameter of a Circle = 2r = 2 * radius
- Circumference of a Circle = 2πr = 2 * π * radius
- Area of a circle is: A = Ï€r² = Ï€ * radius * radius
TIP: Please refer C Program to Calculate Area Of a Circle article to understand the various ways to calculate Area of a Circle.
Source code:
/* C Program to find Diameter, Circumference, and Area Of a Circle */
#include<stdio.h>
#define PI 3.14
int main()
{
float radius, area, circumference, diameter;
printf("\n Please Enter the radius of a circle : ");
scanf("%f",&radius);
diameter = 2 * radius;
circumference = 2 * PI * radius;
area = PI * radius * radius;
printf("\n Diameter Of a Circle = %.2f\n", diameter);
printf("\n Circumference Of a Circle = %.2f\n", circumference);
printf("\n Area Of a Circle = %.2f\n", area);
return 0;
}



No comments:
Post a Comment