Our teacher gave us some problems to work for class but I dont see anywhere in the book that explains these. Im sure it is something simple that im overlooking because im good in math. Could someone show me how to work these. Thanks in advance. Following the pseudocode below, what is the value of X if Y = 10? X=0 If Y > 10 then X=5 Else If Y < 20 then X=7 Else X=9

Yes, You are correct. Also, the last branch will never trigger no matter what is the value of Y. And to finding an answer: if You can't figure out the end result by reading a description/pseudocode/whatever, but can see/understand the algorithm, just write a small test program and simply get the result

X=5 for all Y values greater than 10. For values less than 10 e.g. Y=8, Y=9, Y=9.999999999 (not exactly Y=10) X is always 9. 10 value for Y is a "critical" value where the second if/else conditional works.

He didn't understand it at first. I thought it was pretty easy. I am sure there was something very specific he wasn't understanding.

much more readable once you indent it Code: X=0 If Y > 10 then X=5 Else If Y < 20 then X=7 Else X=9 when using a language that uses closing blocks for if it will be even more readable Code: X=0 If Y > 10 then X=5 Else If Y < 20 then X=7 Else X=9 Endif Endif

It makes no sense at all, especially the first else. Else means that Y<10 and "if Y<20" is redundant. Because if Y<10 then of course Y<20, that part is captain obvious.

@Drone Uhm, it's not Y<10 and Y<20 it's Y>10 and Y<20 Yet, the last else is redundant, 'cause it will never trigger (as I said in my 1st reply )

No, it's y<10. They wrote: It means that whatever comes after the "else" operator can happen only when y<10

Okay, I won't be playing word games. Graphical representation: Edit: OK, now I see Your point. That thing is quite obvious when looking at that "code". Yet, you wrote it very ambiguously. Ambiguously enough to confuse me into thinking You were trying to say a completely different thing. If You would be less ambiguous next time, I would be grateful. Thank You!

Would look a lot easier if: X = 0; if (Y > 10) then x = 5; elseif ( Y < 20 ) then X = 7; else x = 9; end if Sometimes pseudocode is just more confusing.