Computers in Engineering WWW Site - Example 2.4

Example 2.4


FORTRAN Version

!
      PROGRAM P24
!
!
!     CONVERSIONS IN EXPRESSIONS
!
      IMPLICIT NONE
      REAL :: A, B
!
      PRINT *, 'This is Program >> P24  - REAL Operations'
!
!
!     REAL OPERATIONS
!
      A = 1.5
      B = 3.0
      PRINT *,' A+B = ',A+B
      PRINT *,' A-B = ',A-B
      PRINT *,' A*B = ',A*B
      PRINT *,' A/B = ',A/B
!
      STOP
      END PROGRAM P24
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 >> P24  - REAL Operations
 A+B =     4.50000    
 A-B =    -1.50000    
 A*B =     4.50000    
 A/B =    0.500000    

Pascal Version

{
     Conversions in expressions
}
PROGRAM p24 (input, output);
VAR
  a, b : REAL;
{
     Real operations
}
BEGIN
  a := 1.5;
  b := 3.0;
  writeln (' a+b = ', a+b);
  writeln (' a-b = ', a-b);
  writeln (' a*b = ', a*b);
  writeln (' a/b = ', a/b)
END.

Last modified: 21/07/97