📜  Fortran-决策

📅  最后修改于: 2020-11-04 06:14:18             🧑  作者: Mango


决策结构要求程序员确定一个或多个要由程序评估或测试的条件,以及要确定的条件为真的情况下要执行的一条或多条语句,以及可选地,如果条件为真,则要指定其他要执行的语句条件确定为假。

以下是大多数编程语言中常见的典型决策结构的一般形式-

做决定

Fortran提供以下类型的决策构造。

Sr.No Statement & Description
1 If… then construct

An if… then… end if statement consists of a logical expression followed by one or more statements.

2 If… then…else construct

An if… then statement can be followed by an optional else statement, which executes when the logical expression is false.

3 if…else if…else Statement

An if statement construct can have one or more optional else-if constructs. When the if condition fails, the immediately followed else-if is executed. When the else-if also fails, its successor else-if statement (if any) is executed, and so on.

4 nested if construct

You can use one if or else if statement inside another if or else if statement(s).

5 select case construct

select case statement allows a variable to be tested for equality against a list of values.

6 nested select case construct

You can use one select case statement inside another select case statement(s).