From the course: Introduction to Fortran

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Conditional constructs

Conditional constructs - FORTRAN Tutorial

From the course: Introduction to Fortran

Conditional constructs

- [Instructor] Conditional constructs are how your programs can make decisions. We'll discuss two conditional constructs, if and select case. And I'll briefly mention two others available in the language, select type and select rank. The first conditional construct is the if construct. It has two forms with syntax as shown here. A logical_expression is one that evaluates to true or false. The way this works is that for the first form, only those statements following the first expression that evaluates to true are executed or if the else statement is present and no expression evaluates to true, then those statements are executed. In the single statement form, the statement is only executed if the expression evaluates to true. The other conditional construct we'll discuss is the select case construct with the syntax as shown here. The way this construct works is similar to the if construct and in fact could be…

Contents