<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi all,<br>
<br>
Wondering if some kind soul who is good with desk checks / pseudo
code can help me out here. We are about to commence OC2 (running a
week late) and I have given my students some algorithms to evaluate
for revision. On one in particular I realised I made an error of
logic when evaluatiing it myself and have now confused my self to
point of frustration. It's the one below. It has two count loops
which it uses to select data in an array but they both have
identical conditions. As I am currently reading it values will never
be passed to the second loop as the evaluation condition that ends
the first loop will also end the second???? Scratches head......sure
I'm failing to see obvious! Can anyone help pls<br>
<br>
Brett<br>
<style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small><b>Question
12:</b></small></small></font></font></small></small></p>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>The
following diagram shows the contents of an array of
records used for
mixing colours.</small></small></font></font></small></small></p>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>The
name of the array is ‘COLOUR’.</small></small></font></font></small></small></p>
<small><small><font face="Garamond, serif"><font style="font-size:
11pt;" size="2"><small><small>The
algorithm below is used to calculate colour values,
using an array.</small></small></font></font></small></small>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>BEGIN</small></small></font></font></small></small></p>
<p style="text-indent: 1.27cm; margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>SET
TOTAL TO 0</small></small></font></font></small></small></p>
<p style="text-indent: 1.27cm; margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>SET
COUNTER TO 1</small></small></font></font></small></small></p>
<p style="text-indent: 1.27cm; margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>WHILE
COUNTER < 4</small></small></font></font></small></small></p>
<p style="margin-left: 1.27cm; text-indent: 1.27cm; margin-bottom:
0cm;" lang="en-US"><small><small>
<font face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>TOTAL
= TOTAL + COLOUR [COUNTER] . GREENVALUE</small></small></font></font></small></small></p>
<p style="margin-left: 1.27cm; text-indent: 1.27cm; margin-bottom:
0cm;" lang="en-US"><small><small>
<font face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>ADD
1 TO COUNTER</small></small></font></font></small></small></p>
<p style="text-indent: 1.27cm; margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>ENDWHILE</small></small></font></font></small></small></p>
<p style="text-indent: 1.27cm; margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>WHILE
COUNTER < 4</small></small></font></font></small></small></p>
<p style="margin-left: 1.27cm; text-indent: 1.27cm; margin-bottom:
0cm;" lang="en-US"><small><small>
<font face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>TOTAL
= TOTAL + COLOUR [COUNTER] . REDVALUE</small></small></font></font></small></small></p>
<p style="margin-left: 1.27cm; text-indent: 1.27cm; margin-bottom:
0cm;" lang="en-US"><small><small>
<font face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>ADD
1 TO COUNTER</small></small></font></font></small></small></p>
<p style="text-indent: 1.27cm; margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>ENDWHILE</small></small></font></font></small></small></p>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>PRINT
TOTAL</small></small></font></font></small></small></p>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>END</small></small></font></font></small></small></p>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><br>
</small></small></p>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>What
will be the output of this algorithm?</small></small></font></font></small></small></p>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>(A)
10</small></small></font></font></small></small></p>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>(B)
11</small></small></font></font></small></small></p>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>(C)
18</small></small></font></font></small></small></p>
<p style="margin-bottom: 0cm;" lang="en-US"><small><small><font
face="Garamond, serif"><font style="font-size: 11pt;"
size="2"><small><small>(D)
25</small></small></font></font></small></small></p>
<br>
<p></p><p><b>Important - </b>This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Early Childhood Development.</p>
</body>
</html>