Skip to main content
Engineering LibreTexts

6.3: Example

  • Page ID
    54265
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Below is an example program that calculates the area of a circle. The program will declare the appropriate variables, read the radius, calculate the circle area, and display the result.

    program circle
    ! Program to calculate the area of a circle
    
    ! Declare variables
    implicit none
    real :: radius, area
    real, parameter :: pi = 3.14159
    
    ! Display initial header and blank line
        write (*,*) "Circle Area Calculation Program"
        write (*,*)
    
    ! Prompt for and read the radius
        write (*,*) "Enter Circle Radius"
        read (*,*) radius
    
    ! Calculate the circle area
        area = pi * radius**2
    
    ! Display result
        write (*,*) "Circle Area:    ", area
    
    end program circle
    

    The comments are not required, but help make the program easier to read and understand. If the program does not work at first, the comments can aid in determining the problem.


    This page titled 6.3: Example is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Ed Jorgensen via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?