003. do
loop#
topic: Loops
The primary looping construct in Fortran is do
… end do
.
A program to print the sum the squares of the integers from 1 to 5 is
implicit none
integer :: i, ssq
ssq = 0
do i = 1, 5
ssq = ssq + i**2
end do
print *, "sum of squares is ", ssq
end
sum of squares is 55
The primary looping construct in Fortran is do ... end do. A program to print the sum the squares of the integers from 1 to 5 is
— FortranTip (@fortrantip) December 17, 2021
implicit none
integer :: i,ssq
ssq = 0
do i=1,5
ssq = ssq + i**2
end do
print*,"sum of squares is ",ssq
end
- 1
Compiled using
GNU Fortran (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
with no flags