PROGRAM Table_of_Values !----------------------------------------------------------------------- ! Program demonstrating the use of formatted output to print a table ! of values of N, the square and cube of N, and the square root of N ! for N = 1, 2, ..., LastNumber, where the value of LastNumber is read ! during execution. Variables used are: ! N : counter ! LastNumber : last value of N ! ! Input: LastNumber ! Output: Table of values of N, N**2, N**3, and square root of N !----------------------------------------------------------------------- IMPLICIT NONE INTEGER :: N, LastNumber PRINT *, "Enter last number to be used:" READ *, LastNumber ! Print headings PRINT '(// 1X, A8, T12, A8, T22, A8, T32, A9 / 1X, 40("="))', & "Number", "Square", " Cube", "Sq. root" ! Print the table DO N = 1, LastNumber PRINT '(1X, I6, 2I10, 2X, F10.4)', & N, N**2, N**3, SQRT(REAL(N)) END DO STOP END PROGRAM Table_of_Values