Javatpoint Logo
Javatpoint Logo

C Program to Calculate Area and Circumference of Circle

The C programming language has been the foundation of software development for decades. Developed in the early 1970s, C became one of the most widely used and important programming languages. Its ease of use, functionality, and portability has made it a favorite for many applications. In this post, we will look at the C language's grammar, data types, control structures, functions, and libraries. This course will give you a strong understanding of the principles of C programming, whether you are a novice or an experienced programmer.

Dennis Ritchie developed C at Bell Labs for program design. Because of its low power and direct interface to the hardware, it was a good choice for operating systems and compilers. C grew in popularity over time, becoming the basis for many other programming languages, including C++, Java, and Objective-C. Its legacy can be seen in current language and policies.

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 provides a wide variety of data formats, including integers, floating point numbers, characters, and arrays. Variables are used to store and manipulate data in the software. A variable must have its data type declared before it can be used. C supports important data types such as int and float.

Control structures allow programmers to direct the execution of C code. Control structures in C include if-else statements, loops (such as for, while, and do-while), and switch statements. You may use these structures to create conditional judgments, repeat code blocks, and conduct different actions based on different values.

C functions enable code reuse and modular programming. They include code that may be accessed from anywhere in the software. For input/output operations, C has standard library functions such as printf and scanf. C also allows you to write your own functions to do certain tasks.

C's standard input/output library provides file-handling features. You can read and write the files and change file pointers for random access. File handling is required for operations such as data storage, file manipulation, and file system interaction.

The Area and Circumference of a Circle:

Since it is one of the fundamental geometric shapes, understanding the characteristics of the circle is essential for many fields of mathematics and real-world applications. Two crucial factors are a circle's perimeter and area. In this post, we will look at how to compute these important numbers using the radius or diameter of a circle.

C Program to Calculate Area and Circumference of Circle

The circumference of a circle may be determined using one of two commonly used formulas: one based on the radius and the other on the diameter. The formula C = 2πr, where C stands for circumference and r for radius, uses the radius. Instead, you can use the formula C = d, where d is the diameter if you are aware of it. Pi is a mathematical constant having a value of about 3.14159. By putting the radius or diameter values into the corresponding formula, you may find the circumference of a circle.

A formula based on the radius or diameter is used to calculate the area of a circle. A = πr^2, where A stands for area and r for radius, is the formula for computing the area. If you already know the diameter, you may determine it using the equation A = π(d/2)^2., which is yet another representation of the number pi. By inputting known numbers for the radius or diameter into the appropriate formula, you may determine the area of a circle.

Let us understand the calculation of the Area and the Circumference of the circle in a simple C program:

C program:

Output:

C Program to Calculate Area and Circumference of Circle
Next TopicCharacter Set in C





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA