Skip to main content
Engineering LibreTexts

9.6: Exercises

  • Page ID
    54284
  • \( \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 are some quiz questions and project suggestions based on this chapter.

    Quiz Questions

    Below are some quiz questions.

    1. What will happen when an exit statement is executed?
    2. How many exit statements can be included in a loop?
    3. What will happen when a cycle statement is executed?
    4. How many cycle statements can be included in a loop?
    5. If there are multiple cycle statements in a loop, which one will be executed?
    6. What is the output of the following Fortran statements. Assume sum and i are declared as integers.
      sum = 0
      do i = 1, 5
          sum = sum + i
      end do
      write (*,*) "The SUM is:", sum
      
    7. What is the output of the following Fortran statements. Assume i and j are declared as integer.
      write (*,*) "start"
      do i = 1, 3
          do j = 1, 2
              write (*,*) i, " * ", j, " = ", (i*j)
          end do
      end do
      write (*,*) "end"
      
    8. Are the following Fortran statements valid or invalid? If valid, what will happen?
      do i = 3, 2
          write (*,*) i
      end do
      
    9. Are the following Fortran statements valid or invalid? If valid, what will happen?
      do i = 3, 2
          if ( i == 3 ) then
              write (*,*) i
          end do
      end if
      
    10. What is the limit of statements that can be included in a loop?
    11. When IF statements (any form) are nested inside a loop, what must be done to ensure the statements are valid?

    Suggested Projects

    Below are some suggested projects.

    1. Type in the difference program, compile, and execute the program. Test the program on a series of different input values.
    2. Type in the date check program, compile, and execute the program. Test the program on a series of different input values.
    3. Write a program to calculate the range that a ball would travel when it is thrown with an initial velocity \(v_0\) and angle \(\theta\). Based on an initial velocity provided by the user, calculate the range every 5 degrees for angles between 5 and 85 degrees. If we assume negligible air friction and ignore the curvature of the earth, a ball that is thrown into the air from any point on the earth's surface will follow a parabolic flight path.
      The parabolic flight path.
      The range (distance between the initial origin and final impact) is determined by the formula: \[ \textit{range} = -\frac{2v^{2}_{0}}{g} \cos \theta \sin \theta \nonumber\]where \(v_0\) is the initial velocity of the ball, \(\theta\) is the angle of the throw, and \(g\) is the acceleration due to the earth's gravity. The value for gravity should be defined as a constant and set to \(-9.81\) meters per second.
      Note, the intrinsic trigonometric functions work in radians, so the angle in degrees will need to be converted to radians for the calculations. To convert degrees to radians:\[ \textit{radians} = \textit{degrees} \left( \frac{\pi}{180} \right) \nonumber \]Test the program on a series of different input values.

    This page titled 9.6: Exercises 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.