Output is the way in which we provide useful information to the user. The most common method of reaching the user is the monitor, although there are times where other options are available (e.g., printers, speakers).
In Turing, output to the screen is handled by the "put" command. A put command can handle string, integer, or real values. By default, the put command will handle each output on its own line.
put "hello there" %put a string
put 23 %put a simple integer value
put 3 + 5 %put an integer calculation
put 3.1415 %put a simple real value
put 2 / 3 %put a calculation with a real result
It is also possible to combine output values. The most straightforward (and longest) way to do this is by connecting multiple lines together using the ".." continuation operator. Notice that the space between the two pieces of output data must also be included (there are a few ways to do this).
put "hello" ..
put " " ..
put 23
The same output can be accomplished in a much shorter way using commas to separate each output item. The above code can be expressed in an equivalent way using a single line. Different data types can be mixed into a single line of output this way.
put "hello", " ", 23
When formatting the output, it is often desirable to have some empty lines to create some visual space. An empty line can be easily created using an empty string, or "".
put "" %inserts a blank line
Comments (0)
You don't have permission to comment on this page.