!
PROGRAM P32
!
!
! Simple loop in FORTRAN 90
!
IMPLICIT NONE
INTEGER :: I,J
REAL :: SUM,COUNT,AVE
!
PRINT *, 'This is Program >> P32 - Relational IF'
!
! READ DATA
!
READ *,I
!
DO J=1,I
READ * ,SUM ,COUNT
IF(COUNT == 0.0)STOP ! or EXIT
AVE=SUM/COUNT
PRINT * ,'SUM=', SUM
PRINT * ,'COUNT=', COUNT
PRINT * ,'AVERAGE=', AVE
END DO
STOP
END PROGRAM P32
DATA:
2 120.0 10.0 100.0 0.0OUTPUT:
+--------------------------------------------------+
| 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 >> P32 - Relational IF
SUM= 120.000
COUNT= 10.0000
AVERAGE= 12.0000
PROGRAM p32 (input, output);
VAR
sum, count, ave : REAL;
BEGIN
readln (sum, count );
WHILE ( count <> 0.0 ) DO
BEGIN
ave := sum/count;
writeln ('sum =', sum );
writeln ('count =', count );
writeln ('average =', ave );
readln (sum, count )
END
END.
DATA:
120.0 10.0 100.0 0.0
Last modified: 21/07/97