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 strength 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: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">** 2) No blank spaces ** <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px;">** 3 **** ) They are case sensitive (Example and example are 2 different names)**  <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px;">** 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: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">**Task:** Complete the following exercises in your notebook.

<span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">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: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">“martha” ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">23 ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">2.34 ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">-1 ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">34.89 ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">“-2” ||  ||

<span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">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: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Variable name || <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Correction ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">var first name ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">var 3example ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">var put ||  ||
 * <span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">var math ||  ||

<span style="font-family: Arial,Helvetica,sans-serif; font-size: 16px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">**Make sure you memorize the four declaration rules**