📅  最后修改于: 2020-11-04 06:14:36             🧑  作者: Mango
在某些情况下,您需要多次执行一个代码块。通常,语句是按顺序执行的:函数的第一个语句首先执行,然后执行第二个,依此类推。
编程语言提供了各种控制结构,允许更复杂的执行路径。
循环语句使我们可以多次执行一个语句或一组语句,以下是大多数编程语言中循环语句的一般形式-
Fortran提供以下类型的循环结构来处理循环需求。单击以下链接以查看其详细信息。
Sr.No | Loop Type & Description |
---|---|
1 | do loop
This construct enables a statement, or a series of statements, to be carried out iteratively, while a given condition is true. |
2 | do while loop
Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body. |
3 | nested loops
You can use one or more loop construct inside any other loop construct. |
循环控制语句从其正常顺序更改执行。当执行离开作用域时,在该作用域中创建的所有自动对象都将被销毁。
Fortran支持以下控制语句。单击以下链接以查看其详细信息。
Sr.No | Control Statement & Description |
---|---|
1 | exit
If the exit statement is executed, the loop is exited, and the execution of the program continues at the first executable statement after the end do statement. |
2 | cycle
If a cycle statement is executed, the program continues at the start of the next iteration. |
3 | stop
If you wish execution of your program to stop, you can insert a stop statement |