EXERCISE+2

**EXERCISE 2**
//**Sequential structures: __variable declarations and types__**//

//**Variable Types**// A variable in Turing is similar to one in math. It means that a value can vary. A variable can be one of several types.


 * **int** || an integer, i.e., -1, 45, 8,0,37 ||
 * **real** || the set of numbers containing decimals, i.e., 4.37, -2.1234, etc. ||
 * **string** || any characters that are available from the keyboard, i.e., “dog”, “123 Maple Lane”, “13”, etc. note the quotation marks! ||
 * char || any string of length 1 ||

On the computer, when a **variable** is created (**declared**), a space in **RAM** is created having the declared variable’s **identifier** (name) as its location. In Turing, **//a variable and its type must be declared before it can be used//**. For example: var first: string

var  age:int **Variable identifiers** (names) __must__ follow certain rules: ** 1) They must begin with a letter ** <span style="font-family: arial,helvetica,sans-serif; font-size: 120%;">** 2) No blank spaces ** <span style="font-family: arial,helvetica,sans-serif; font-size: 120%;">** 3) They are case sensitive (Example and example are 2 different names)** <span style="font-family: arial,helvetica,sans-serif; font-size: 120%;">** 4) They can’t use reserved words (words which are already used by Turing, i.e., put, var, etc.)**

<span style="font-family: arial,helvetica,sans-serif; font-size: 120%;">**Task:** Complete the following exercises in your notebook. 1) State the kind of variable given the contents of the variable


 * <span style="display: block; font-family: arial,helvetica,sans-serif; text-align: center;">variable contents || <span style="display: block; font-family: arial,helvetica,sans-serif; text-align: center;">variable type ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">“martha” ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">23 ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">2.34 ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">-1 ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">34.89 ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">“-2” ||  ||

<span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">2) Correct any errors in the following variable names if there is no error write OK


 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">Variable name || <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">Correction ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">var first name ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">var 3example ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">var put ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">var math ||  ||

<span style="font-family: Arial,Helvetica,sans-serif; font-size: 120%;">**Make sure you memorize the four declaration rules**