• 100% Satisfaction Guarantee
jeff, Computer Software Engineer
Category: Programming
Satisfied Customers: 153
Experience:  7 yrs. of professional programming experience. BS and MS in Computer Science.
31939911
jeff is online now

# 1)Suppose w, x, y and z are integer variables and initialized

1)Suppose w, x, y and z are integer variables and initialized as follows:
w = 2; x = 3; y = 4; z = 5;
In a block of C/C++/Java code, the following statements are executed. What is the value of w after these statements are executed?
{
x = z + y;
y = 2 * x - y;
w= x + w / 2 - z
}
2)With x = 5 and y = 8 and z = 5, what is the value of the variable z after the execution of the
following pseudo-code:

If ((x = 10)) Then
z = z + 1
Else
z = z – 1
End If
3)Let X = 3 and Y = 6. Indicate by entering T or F whether the expression is TRUE or FALSE

NOT(X > 3) AND NOT(Y < X)
4)Write pseudocode to print the numbers 3, 6, 9, 12, 15, 18 and 21 using a for-loop
5) ) Using pseudocode declare a Real number named temperature
6)Using pseudocode declare a variable to store the Julian day (1-366) named JDay.
This is only 6 questions out of 100 on my review sheet for my mid term! Please help as I am soo stuck on these! Thanks
1) Suppose w, x, y and z are integer variables and initialized as follows:

w = 2; x = 3; y = 4; z = 5;

In a block of C/C++/Java code, the following statements are executed.

What is the value of w after these statements are executed?
{
x = z + y;
y = 2 * x - y;
w= x + w / 2 - z
}

Satement 1: x = z + y

x = 5 + 4 = 9

Statement 2: y = 2 * x - y
Remember that x was set to 9 in Statement 1

y = 2 * 9 - 4 = 14

Statement 3: After w = x + w/2 - z is executed

w = 9 + 2/2 - 5 = 5

w = 5 is the final answer

2)
With x = 5 and y = 8 and z = 5, what is the value of the variable z after the execution of the following pseudo-code:

If ((x <= 20) && (y >= 10)) Then
z = z + 1
Else
z = z – 1
End If

The first statement checks if x is less than or equal to 20 AND if y is greater than or equal to 10. The first condition evaluates to true, but the second condition evaluates to false since y is less than 10. Therefore, the entire if statement evaluates to false, and the statement after the Else is executed.

z = z - 1 = 5 - 1 = 4

z = 4 is the final answer

3)Let X = 3 and Y = 6.
Indicate by entering T or F whether the expression is TRUE or FALSE NOT(X > 3) AND NOT(Y < X)

Let's break it down into parts:

(X > 3) = FALSE
NOT (X > 3) = TRUE

(Y < X) = (6 < 3) = FALSE
NOT(Y < X) = TRUE

Putting the two together

NOT(X > 3) AND NOT(Y < X) = TRUE AND TRUE = TRUE

4) Write pseudocode to print the numbers 3, 6, 9, 12, 15, 18 and 21 using a for-loop

This problem can be approached from several different angles:

The first possibility is that we loop from 3 to 21 and add 3 to the loop counter each time we print

For LoopCounter = 3; LoopCounter <= 21; LoopCounter = LoopCounter + 3
Print LoopCounter
Next

---OR we can loop from 1 to 21, and only print out the numbers that are evenly divisible by 3---

For LoopCounter = 1 to 21
If (LoopCounter MOD 3) = 0 Then
Print LoopCounter
End If
Next LoopCounter

5) Using pseudocode declare a Real number named temperature

Final Answer: Declare temperature as Real

or this could be: Declare temperature as Float

it just depends on which way you learned in class. Real is pseudocode, Float is what most real programming languages use.

6) Using pseudocode declare a variable to store the Julian day (1-366) named JDay.

Declare JDay as Integer