Prompting for input

Prompting for input

WRITE(*, has the same meaning as PRINT. WRITE is used for general purpose printing and the asterisk here denotes the standard output device. If we want to prompt the user for input, then we could use PRINT but the output automatically advances to the next line which is not ideal.

WRITE(*,*) is the same as PRINT * so the second asterisk in WRITE denotes list directed output. However, with list directed output, it is not possible to suppress the linefeed. In place of the second asterisk we use a format specifier to describe how the output is to appear. This takes the form of a string enclosed by round brackets. The letter a indicates that the output is a string.

The third argument of WRITE is used to suppress the linefeed.

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited