By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,479 Members | 1,729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,479 IT Pros & Developers. It's quick & easy.

what z=

P: 6
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 ((5 <= 20) && (8 >= 10)) Then
z = 5 + 1
Else
z = 5 1
End If
is z= to 4?
Nov 8 '08 #1
Share this Question
Share on Google+
3 Replies


Expert 10K+
P: 11,448
The variables x and y don't participate in any part of that program snippet so I
don't know why you mentioned them. What happened when you wrote a little
C or C++ program and executed it? This is not an answer-my-silly-riddles forum.

kind regards,

Jos
Nov 8 '08 #2

Ganon11
Expert 2.5K+
P: 3,652
This code depends on the two logical expressions "5 <= 20" and "8 <= 10". Are you telling me you don't have enough math basis to determine the truth value of these expressions?

You're smarter than that, I guarantee it.
Nov 8 '08 #3

Expert 100+
P: 2,415
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 ((5 <= 20) && (8 >= 10)) Then
z = 5 + 1
Else
z = 5 1
End If
is z= to 4?
Umm. Your pseudo-code doesn't make much sense to me, perhaps you meant ...
Expand|Select|Wrap|Line Numbers
  1. if ((x <= 20) && (y >= 10)) Then
  2.     z = x + 1
  3. Else
  4.     z = x - 1
  5. End If
In any case, the key is determining which leg of the If statement executes. The question to answer is whether the If expression is true or false. What do you think? Why do you think so?
Nov 8 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.