Formatted output

List directed input (using READ *) is adequate for most purposes. In contrast, list directed output (using say PRINT *) has its limitations. For example, when outputting REAL numbers, the programmer usually wants to control the number of significant figures that are presented. The next example shows how to do this.

PROGRAM Prog4

PRINT "( a, i2, 4x,a, f6.2,4x,a, e10.3)", &

"Integer:",77,"Float",77.0,"Exponent",77.0

END PROGRAM Prog4

The output is:

Integer:77 Float: 77.00 Exponent: 0.770E+02

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited