C Program To Calculate Area And Circumference Of Circle

C is a simple syntax-processing programming language. C software consists of programs that do a few things. The structure of a typical C program consists of basic functions that are basic implementations. The words end with semicolons , and circle brackets surround code segments. Since C is case-sensitive, both uppercase and lowercase letters are used freely.

C offers a diverse range of data types, such as integers, floating-point numbers, characters, and arrays. In software development, variables play a crucial role in storing and managing data. Before using a variable, it is necessary to declare its data type. C includes essential data types like int and float.

Control constructs enable developers to manage the flow of execution in C programming. Within C, control structures encompass if-else conditions, various types of loops like for, while, and do-while loops, as well as switch statements. These constructs are instrumental in forming conditional evaluations, iterating over code segments, and executing diverse operations depending on distinct values.

C functions facilitate the reuse of code and promote modular programming by providing a way to access specific code from any part of the software. In C, standard library functions like printf and scanf are available for input/output tasks. Additionally, developers can create custom functions to perform specific operations.

C's standard input/output library offers functionality for file management. It enables users to read from and write to files, as well as manipulate file pointers for random access. This capability is essential for tasks like storing data, manipulating files, and interacting with the file system.

The Area and Circumference of a Circle:

As a fundamental geometric form, comprehending the properties of a circle holds significant importance across various mathematical disciplines and practical scenarios. Key aspects to consider are the circumference and area of a circle. This discussion will focus on the methodology for calculating these vital values based on either the radius or diameter of a circle.

The measurement around the outer edge of a circle can be calculated using either of two frequently employed equations: one that relies on the radius and the other on the diameter. The formula C = 2πr, where C represents circumference and r represents radius, makes use of the radius. Alternatively, the formula C = d, where d denotes the diameter, can be utilized if that measurement is known. Pi is a constant in mathematics with an approximate value of 3.14159. By substituting the values of either the radius or diameter into the respective formula, you can determine the circumference of a circle.

A calculation based on the radius or diameter is employed to determine the area of a circle. The formula A = πr^2, where A represents the area and r signifies the radius, is utilized for this computation. In case you are provided with the diameter instead, the equation A = π(d/2)^2 can be used, offering an alternate expression for the mathematical constant pi. By substituting the given values for the radius or diameter into the relevant formula, you can ascertain the area of a circle.

Let's explore how to compute the Area and the Circumference of a circle in a basic C program:

C program:

Example

#include <stdio.h>
#define PI 3.14159
int main() {
    double radius, area, circumference;
printf("Enter the radius of the circle: ");
scanf("%lf", &radius);
    area = PI * radius * radius;
    circumference = 2 * PI * radius;
printf("Area of the circle: %.2lf\n", area);
printf("Circumference of the circle: %.2lf\n", circumference);
    return 0;
}

Output:

Input Required

This code uses input(). Please provide values below: