# Math Help - Outcome table

1. ## Outcome table

Hey guys im really stuck on this question and would appreciate a bit of help.

Give an outcome table for the following code fragment. You should show which line in the fragment determines the outcome for that row.

CODE FRAGMENT 2
case
if r then case
if q then case
if p then x C x + 2 (A)
else x <-- x + 1 (B)
end-case
else x <-- x + 2 (C)
end-case
else case
if p OR q then case
if NOT(p) then x C x + 2 (D)
else x <-- x + 1 (E)
end-case
else x <-- x + 2 (F)
end-case
end-case

2. ## Re: Outcome table

Originally Posted by ianal09
Give an outcome table for the following code fragment.
The "outcome table" is not a universally accepted term in math or computer science. I assume it means the table that shows the final value of x for each combination of truth values of p, q and r. But what is the initial value of x, or do you need to express the final value in terms of the initial one? Also, is C in "x C x + 2" a synonym of <--, i.e., assignment? Are "case" and "end-case" used for grouping only? Other programming languages use "begin" and "end" (Pascal) or curly braces (C, C++, Java) for grouping, and "case" often is a separate choice operator. Finally, on this forum you can put computer code between the [code]...[/code] tags to preserve alignment.

What exactly is your difficulty with this problem? Granted, it is tedious to follow the branching structure for each truth value of p, q and r, but this is not complicated. In fact, even computers can do it very well.

3. ## Re: Outcome table

im totally not sure about that question. That was given to us and no one could understand what it mean only the subject tutor i think its practically like this.
Code:
Give an outcome table for the following code fragment. You should show which line in the fragment determines the outcome for that row.

CODE FRAGMENT 2
case
if  r  then case
if q  then case
if  p     then     x <-- x + 2            (A)
else     x <-- x + 1            (B)
end-case
else    x <-- x + 2                    (C)
end-case
else case
if  p OR q   then case
if NOT(p) then     x <-- x + 2    (D)
else      x <-- x + 1    (E)
end-case
else           x <-- x + 2                (F)
end-case
end-case

4. ## Re: Outcome table

First of all i was given a question just like this
Code:
Derive a fragment of code, involving nested cases and only the elementary expressions p, q and r, equivalent to the following.

CODE FRAGMENT 1
case
if [ (p AND (q AND NOT( r AND p))) OR NOT(p OR NOT(r)) ]
then		x  x + 1
else		x  x + 2
end-case
which i have answer just fine