Area of Circle
Programming
This program calculates the area of a circle using the formula:
Area = π × radius²
Constants
The program uses a parameter to define π as a constant. Parameters are compile-time constants that cannot be modified during program execution.
Implementation
program area_of_circle
implicit none
integer, parameter :: dp = kind(1.0d0)
real(dp) :: radius, area
real, parameter :: pi = 3.14159
print *, "Enter the radius of the circle:"
read *, radius
area = pi * radius**2
print *, "Area of the circle: ", area
end program area_of_circle Example Interaction
Enter the radius of the circle:
5
Area of the circle: 78.539750000000000