C program to find the circumference of a circle
The boundary of a circle is known as the Circumference of a circle.
All the points that form the boundary or the circumference of the circle are equidistant from a single point inside the circle.
The single point that is present inside the circle is also known as the Center of the circle. The distance from the Center of a circle to any point on the circumference is equal. It is regarded as the radius of the very circle.
The formula used to calculate circumference of a circle is: C = dπ
C = 2πr (since d = 2r) where, d and r are the diameter and radius respectively.
Prerequisites:
- Knowing the float and int data types
- C format specifiers
Float data type in C:
The float data type in C represents the floating point numbers, the float values which are specified with a decimal point to separate integer and the fractional parts.
For example, 69.75,6.58..
Floats may also be expressed in scientific notations e or E, which indicates the power of 10.
Int datatype in C:
Integers are whole numbers that can have both zero, positive and negative values but no decimal values. We can use int data type to denote an integer value in C.
C format specifiers:
The format specifiers are used in C for input and output purposes. The compiler can understand that what type of data is in a variable during taking input using the scanf() function and printing using printf() function.
Here, we use % f specifier which represents a floating point number (or) flaot values.
Code:
Here, the circumference of the circle formula, c=2pi (r) is used, where pi equals 22/7.
Output:
To learn C and such courses: