# Printing INTEGERs and REALs with the I and F Descriptors

 WARNING: This example assumes the output is sent to a printer, and as a result, every formatted output contains printer control.

### Problem Statement

Write a program that for each INTEGER in the range of 1 and 10, prints its value, square, cube, square root and the fourth root. You should generate the output as shown below.
```         1    1    2    2    3    3    4    4
....5....0....5....0....5....0....5....0....5
1     1     1   1.0000000   1.0000000
2     4     8   1.4142135   1.1892071
3     9    27   1.7320508   1.3160740
:
:
:
10   100  1000   3.1622777   1.7782794
```

### Solution

```PROGRAM  Squares_and_Roots
IMPLICIT  NONE
INTEGER, PARAMETER :: MAXIMUM = 10
INTEGER            :: i
CHARACTER(LEN=30)  :: Format

Format = "(3I6, 2F12.7)"
DO i = 1, MAXIMUM
WRITE(*,Format)  i, i*i, i*i*i, SQRT(REAL(i)), SQRT(SQRT(REAL(i)))
END DO
END PROGRAM  Squares_and_Roots
```

### Program Input and Output

The output of the program is:
```         1    1    2    2    3    3    4    4
....5....0....5....0....5....0....5....0....5
1     1     1   1.0000000   1.0000000
2     4     8   1.4142135   1.1892071
3     9    27   1.7320508   1.3160740
4    16    64   2.0000000   1.4142135
5    25   125   2.2360680   1.4953488
6    36   216   2.4494898   1.5650846
7    49   343   2.6457512   1.6265765
8    64   512   2.8284271   1.6817929
9    81   729   3.0000000   1.7320508
10   100  1000   3.1622777   1.7782794
```

### Discussion

• We use a counting DO loop to generate the value of i in the range of 1 and 10. In each iteration of this loop, we print the value of i, i*i (square), i*i*i (cube), SQRT(REAL(i)) (square root), and SQRT(SQRT(REAL(i))) (fourth root). Since i is an INTEGER, before we compute the square root and fourth root, it is converted to a REAL with intrinsic function REAL().
• Each of the first three INTEGERs is printed using 6 positions, and each of the roots is printed using 12 positions with seven digits for the fractional part. Therefore, the format is:
```CHARACTER(LEN=30)  :: Format

Format = "(3I6, 2F12.7)"
```
• Note that the first I6 includes the printer control character. Since the value of i is in the range of 1 and 10, it only uses the last two positions of the assigned 6 and, as a result, the first position is always a space.