Fractional Data Types and Constants
Source Code
Run Output
Code Understanding
This program calculates the area and circumference of a circle when the radius is given by the user.
• #include allows input and output commands.
• const float PI = 3.14159; defines a constant value for π (pi).
• float, double, and long double are data types used for decimal numbers with different precisions.
• cin >> radius; takes the radius from the user.
• area = PI * radius * radius; uses the formula π × r² to find the area.
• circum = 2 * PI * radius; uses the formula 2 × π × r to find the circumference.
• cout statements display the results on the screen.
• return 0; ends the program.
