C Program to Find Diameter, Circumference, and Area of a Circle

C Program to Find Diameter, Circumference, and Area of a Circle

C program to find diameter, circumference, and area of a circle; Through this tutorial, we will learn how to find or calculate the diameter, circumference and area of a circle using the formula, function, and math modules in c programs.

Programs and Algorithm to Find the Area of a Circle

  • Algorithm To Find Diameter, Circumference, and Area of a Circle
  • C Program to Find Diameter, Circumference, and Area of a Circle using Formula
  • C Program to Find Diameter, Circumference, and Area of a Circle using Function
  • C Program to Find Diameter, Circumference, and Area of a Circle using Math Module

Algorithm To Find Diameter, Circumference, and Area of a Circle

Use the following algorithm to write a program to find diameter, circumference and area of a circle; as follows:

  1. START PROGRAM.
  2. TAKE RADIUS AS INPUT FROM USER.
  3. FIND AREA OF DIAMETER, CIRCUMFERENCE, CIRLCE USING THE FOLLOWING FORMULAS:
    1. diameter = 2 * radius;
    2. circumference = 2 * PI * radius;
    3. area = PI * radius * radius;
  4. PRINT “AREA OF CIRCLE, DIAMETER, CIRCUMFERENCE “
  5. END PROGRAM.

C Program to Find Diameter, Circumference, and Area of a Circle using Formula

/* 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;
}

The output of the above c program; as follows:

Please Enter the radius of a circle : 5
Diameter Of a Circle = 10.00

 Circumference Of a Circle = 31.40

 Area Of a Circle = 78.50

C Program to Find Diameter, Circumference, and Area of a Circle using Function

/* C Program to find Diameter, Circumference, and Area Of a Circle */

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

double find_Diameter(double radius);
double find_Circumference(double radius);
double find_Area(double radius);

int main()
{
  float radius, area, circumference, diameter;
 
  printf("\n Please Enter the radius of a circle : ");
  scanf("%f",&radius);
 
  diameter = find_Diameter(radius);
  circumference = find_Circumference(radius);
  area = find_Area(radius); 
 
  printf("\n Diameter Of a Circle = %.2f\n", diameter);
  printf(" Circumference Of a Circle = %.2f\n", circumference);
  printf(" Area Of a Circle = %.2f\n", area);
 
  return 0;
}

double find_Diameter(double radius)
{
   return 2 * radius;
}

double find_Circumference(double radius)
{
   return 2* M_PI * radius;
}
double find_Area(double radius)
{
   return M_PI * radius * radius;
}

The output of the above c program; as follows:

Please Enter the radius of a circle : 5
Diameter Of a Circle = 10.00
 Circumference Of a Circle = 31.42
 Area Of a Circle = 78.54

C Program to Find Diameter, Circumference, and Area of a Circle using Math Module

/**
 * C program to calculate diameter, circumference and area of circle
 */

#include <stdio.h>
#include <math.h> // Used for M_PI

int main()
{
    float radius, diameter, circumference, area;
    
    /*
     * Input radius of circle from user
     */
    printf("Enter radius of circle: ");
    scanf("%f", &radius);

    /*
     * Calculate diameter, circumference and area of circle
     */
    diameter = 2 * radius;
    circumference = 2 * M_PI * radius;
    area = M_PI * (radius * radius);

    /*
     * Print all results
     */
    printf("Diameter of circle = %.2f units \n", diameter);
    printf("Circumference of circle = %.2f units \n", circumference);
    printf("Area of circle = %.2f sq. units ", area);

    return 0;
}

The output of the above c program; as follows:

Enter radius of circle: 10
Diameter of circle = 20.00 units 
Circumference of circle = 62.83 units 
Area of circle = 314.16 sq. units 

Recommended C Programs

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *