Computers in Engineering WWW Site - Example 2.6

# Example 2.6

#### FORTRAN Version

```!
PROGRAM P26
!
!
!     CONVERSIONS IN THE
!     ASSIGNMENT STATEMENT
!
IMPLICIT NONE
INTEGER :: I, J
REAL :: A, B
!
PRINT *, 'This is Program >> P26  - Conversion Rules'
!
!
!     INTEGER = INTEGER
!
I = 1
J = I
PRINT *,' I =',I, '  J =',J
!
!     REAL = REAL
!
A = 1.5
B = A
PRINT *,' A=',A
PRINT *,' B=',B
!
!     REAL = INTEGER
!
A = 2
B = I
PRINT *,' A=',A
PRINT *,' B=',B
!
!     INTEGER = REAL
!
I = 1.5
J = A
PRINT *,' I =',I, '  J =',J
!
STOP
END PROGRAM P26
```
OUTPUT:
```
+--------------------------------------------------+
|     32-bit Power for Lahey Computer Systems      |
|   Phar Lap's 386|DOS-Extender(tm) Version 7.0    |
|  Copyright (C) 1986-94 Phar Lap Software, Inc.   |
|           Available Memory = 14880 Kb            |
+--------------------------------------------------+

This is Program >> P26  - Conversion Rules
I =           1  J =           1
A=    1.50000
B=    1.50000
A=    2.00000
B=    1.00000
I =           1  J =           2
```

#### Pascal Version

```{
Conversions in the assignment statement
}
PROGRAM p26 (input, output);
VAR
i, j : INTEGER;
a, b : REAL;
{
Integer := integer
}
BEGIN
i := 1;
j := i;
writeln (' i =', i, ' j =', j);
{
Real := real
}
a := 1.5;
b := a;
writeln (' a=', a);
writeln (' b=', b);
{
Real := integer
}
a := 2;
b := i;
writeln (' a=', a);
writeln (' b=', b)
END.
```