It 104 Unit 3

605 Words3 Pages
Short Answers: 5. What two things must you normally specify in a variable declaration? * the variable type and identifier. 6. What value is stored in uninitialized variables? * Some languages assign a default value as 0 to uninitialized variable. In many languages, however, uninitialized variables hold unpredictable values. Algorithm Workbench: 3. Write assignment statements that perform the following operations with the variables a, b, and c. a) Adds 2 to a and stores the result in b * b=a+2 b) Multiplier b times 4 and stores the result in a * a=b*4 c) Divides a by 3.14 and stores the result in b * b=a/3.14 d) Subtract 8 from b and stores the result in a * a=b-8 4. Assume the variables result, w, x, y, and z are all integers, and that w=5, x=4, y=8, and z=2. What value will be stored in result in each of the following statements? a) Set result = x + y * 12= x + y b) Set result = z + 2 * 4=z * 2 c) Set result = y / x * 2=y / x d) Set result =y – z * b=y – z 5. Write a pseudocode statement that declares the variable cost so it can hold real numbers. * Dim cost1 As Double = 0 6. Write a pseudocode statement that declares the variable total so it can hold integers. Initialize the variable with the value 0. * Dim cost1 As Integer = 0 7. Write a pseudocode statement that assigns the value27 to the variable count. * Dim count As Integer = 2 8. Write a pseudocode statement that assigns the sum of 10 and 14 to the variable total. * Total = 10 + 14 9. Write a pseudocode statement that subtracts the variable downPayment from the variable total and assigns the result to the variable due. * Due = total – downPayment 10. Write a pseudocode statement that multiplies the variable subtotal by 0.15 and assigns the result to the variable totalfee. *

More about It 104 Unit 3

Open Document