24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

11 Format<br />

11.1 Introduction<br />

A format specification used in conjunction with formatted I/O provides a means of specifying the way<br />

internal data is converted to a character string and vice versa. A format specification can be given in two<br />

ways.<br />

1. In a FORMAT statement.<br />

2. As values of character expressions or character arrays.<br />

11.2 The FORMAT Statement<br />

The form of a FORMAT statement is<br />

<br />

label<br />

FORMAT fs<br />

where:<br />

label<br />

fs<br />

is the statement label used by an I/O statement to identify the FORMAT statement.<br />

is a format specification which will be described later.<br />

Example:<br />

REAL X<br />

X = 234.43<br />

PRINT 100, X<br />

100 FORMAT(F10.2)<br />

END<br />

In the previous example, the PRINT statement uses the format specification in the FORMAT statement<br />

whose statement label is 100 to display the value of X.<br />

11.3 FORMAT as a Character Expression<br />

Instead of specifying the statement label of a FORMAT statement, a character expression can be used. The<br />

previous example could be modified as follows and achieve the identical result.<br />

FORMAT as a Character Expression 225

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!