From the course: Introduction to Fortran
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Looping constructs - FORTRAN Tutorial
From the course: Introduction to Fortran
Looping constructs
- [Instructor] Loops are how we can have sections of our code execute repeatedly. There are a couple of forms of loop in Fortran so let's take a look at them. Here's the syntax for a loop with a loop index variable. Note that the increment is optional and will be one if not specified. The loop index variable must be an integer and so must the expressions for start, end and increment. The loop index is assigned the value of start. Then it is checked whether it has a value greater than end. Or if the increment is negative if it is less than end. If it does, execution moves to the statement after the end do statement. If not, the statements in the loop are executed. Then the increment value is added to the index and the check is repeated. Note that the values for start, end, and increment are evaluated only once, thus once a loop begins execution, it is not possible to change how many times it will execute. Here's the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Chapter intro: The basics47s
-
(Locked)
Variables3m 32s
-
(Locked)
Detailed variable behavior demonstration5m 38s
-
(Locked)
Named constants1m 55s
-
(Locked)
Expressions, order of operations, and type conversions2m 57s
-
(Locked)
Expression demonstration5m 33s
-
(Locked)
Conditional constructs5m 36s
-
(Locked)
Looping constructs4m 37s
-
(Locked)
Arrays3m 49s
-
-
-
-