它重复语句或一组语句,当给定的条件为真。它测试的条件执行在循环体之前。
do while (logical expr) statements end do流程图
示例
program factorial implicit none ! define variables integer :: nfact = 1 integer :: n = 1 ! compute factorials do while (n <= 10) nfact = nfact * n n = n + 1 print*, n, " ", nfact end do end program factorial
当上述代码被编译和执行时,它产生了以下结果:
1 1 2 2 3 6 4 24 5 120 6 720 7 5040 8 40320 9 362880 10 3628800