PT 1420 Assignment 3

Topics: Real number, Integer, Computer programming Pages: 2 (676 words) Published: October 27, 2014

Short answers
5. What two things must you normally specify in a variable declaration? You must specify the variable type and an identifier.
int n; // type - int, identifier - n
6. What value is stored in uninitialized variables?
is a variable that is declared but is not set to a definite known value before it is used. 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. Multiplies b times 4 and stores the result in a
c. Divides a by 3.14 and stores the result in b
d. Subtracts 8 from b and stores the result in a
Assignment statements that perform operations with the variables a, b, and c* (*Actually none of these operations involves the variable c at all... is this an error, or a 'trick answer'?): b = a + 2

a = b * 4
b = a / 3.14
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

b. Set result = z * 2
c. Set result = y / x
d. Set result = y – z
result = x++ - y;
Answer -4
result = 4 – 8 = -4
result = ++w + y;
Answer
w = w + 1 = 5 + 1 = 6
result = 6 + 8 = 14
5. Write a pseudocode statement that declares the variable cost so it can hold real numbers. Declare Real price= 0.00
Display "the original price."
Input item original price
Display "price"
6. Write a pseudocode statement that declares the variable total so it can hold integers. Initialize the variable with the value 0. Declare Real price= 0.00
Display "the original price."
Input item original price
Display "price"
7. Write a pseudocode statement that assigns the value 27 to the variable count. count := 27
8. Write a pseudocode statement that assigns the sum of 10 and 14 to the variable total. /*Declare variables
Total (number (3)) = 0
A (number (2)) =10
B (number (2)) =14
Begin Total=A+B
End...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • PT 1420 Unit 4 Research Assignment 1 Essay
  • case assignment 3 Essay
  • capstone exam. pt. 3 Essay
  • assignment 3 Essay
  • Assignment 3 Essay
  • Assignment #3 Essay
  • Assignment 3 Essay
  • assignment 3 Essay

Become a StudyMode Member

Sign Up - It's Free
افلام 2015 | UPcoming Vice (2018) | Three s company