003. do loop#

topic: Loops

The primary looping construct in Fortran is doend do. A program to print the sum the squares of the integers from 1 to 5 is

do-enddo.f90 | | Godbolt Compiler Explorer logo | Fortran logo#
implicit none

integer :: i, ssq

ssq = 0
do i = 1, 5
   ssq = ssq + i**2
end do
print *, "sum of squares is ", ssq

end
Output1#
 sum of squares is           55


1

Compiled using GNU Fortran (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0 with no flags