Breaking

Tuesday, February 19, 2019

#6: C Program to find Diameter,Area,Circumference of Circle

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:

  1. Diameter of a Circle = 2r = 2 * radius
  2. Circumference of a Circle = 2Ï€r = 2 * Ï€ * radius
  3. 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;
}

Output Console:


No comments:

Post a Comment

Popular Posts

Post Top Ad

Your Ad Spot

Pages