How would I modify the program so it doesn't generate an output for integers that are multiples of 5? (e.g. if range was 1-20, then no lines would be printed for 5, 10, 15, 20.)(adsbygoogle = window.adsbygoogle || []).push({});

program squares

implicit none

integer*2 start, finish, i

! ----------------------------------------------Prompt and Input

print*, "Enter the range (two integers) ..."

read*, start, finish

! ----------------------------------------------Validation & Processing

if (start .GT. finish) then

print*, "Invalid: the start must be less than the end value!"

else if (start .LT. 0) then

print*, "Invalid: the range must not have negative values!"

else

do i = start, finish

write(*,*) i, sqrt(i*1.)

end do

end if

! ----------------------------------------------

end

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# [FORTRAN] do-loop problem

Loading...

Similar Threads - FORTRAN loop problem | Date |
---|---|

Fortran 90 loop output to file | Feb 5, 2017 |

Fortran infinite loop | Sep 9, 2015 |

Fortran : generating different output files in a loop | Jun 30, 2015 |

Fortran DO loop sequence confusion | Apr 25, 2014 |

Fortran Help (Do Loop) | Feb 11, 2014 |

**Physics Forums - The Fusion of Science and Community**