Easy C Program For Area Of Circle With Solution
Why do we use float data type in C program for area of a circle? What is the mathematical equation for the area of a circle? What are the variables required?
Why do we use float data type in C program for area of a circle? What is the mathematical equation for the area of a circle? What are the variables required?
The float data type is used as we need to input floating values. The output will also have floating values as the value of pi=3.14. The formula for the area of the circle is 3.14*r*r, r is the radius. The variables required are r (radius), pi (3.14), c (area of the circle). This is one of the simplest programs in the C language as the source code is very less and can be written within ten lines.
In C language or C programming, data types are used to define a variable before using in a program and C data type is the data storage format which allows a variable to store data to perform a specific operation. The C language has four (4) data types:
Floating point data type has two (2) types:
With float data type, it allows a variable to store decimal values and has a storage size of 4. You can store values up to six (6) digits after the decimal point, for example, 10.456789. Double data type supports up to ten (10) digits after the decimal point and ranges from 1E–37 up to 1E+37.