Computer Studies‎ > ‎Turing‎ > ‎Turing Tutorial‎ > ‎

Turing 018 — Get

The “get” command is used to get information from the user and store it in a variable. The following program asks for and gets a user’s year of birth:

var birthYear : int
put ”What year were you born? ” ..
get birthYear
put ”You were born in ”, birthYear

Note that the comma in the last line is used to print more than one thing from a single put statement, and in this case works to keep the cursor on the same line as the prompt statement.

Assignment

Write a program that gets your year of birth and the current year. Calculate and output your age.

Remember that all programs must have a user-friendly interface.

Save as "018.t".
Comments