P
popeyerayaz
I want run this by the group for correctness.
The question is as follows:
9. Present an example of a logic bug using pseudocode and explain your
answer. (10 points)
Temperature = 70
if (Temperature >69) and (Temperature < 100 )
THEN
openWindows;
Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.
2. Gentlemen, after reading your advise I had run the code in C++,
then stated it back in pseudocode. I suppose the programmer could
mistakenly use the "AND" && operator instead of the "OR" || operator
which I found the latter to run a loop which I couldn't end, not even
with a ctrl-c, and had to push the power button in to turn off my
computer (please keep that in mind). Also found that the temperatures
reflected would better reflect opening the windows and not closing
them.
Temperature = 70
if (Temperature >69) and (Temperature < 100 )
THEN
openWindows;
Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.
The code generated: numbered list 70-99
------------------------------------------------------------------------------------------------------------------------------------------------------
Temperature = 70
if (Temperature >69) or (Temperature < 100 )
THEN
openWindows;
Won't work because windows will stay closed due to temperature will
always be under 100 degrees the fault lies with the "or" "||" operator
which was used instead of the "and" (&&) operator.
The code generated: an infinite loop of never ending numbers that
crashed my computer.
Thank You,
Ray The code generated: numbered list
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Temperature = 70
if (Temperature >69) or (Temperature < 100 )
THEN
openWindows;
Won't work because windows will stay closed due to temperature will
always be under 100 degrees the fault lies with the "or" "||" operator
which was used instead of the "and" (&&) operator.
The code generated: an infinite loop of never ending numbers that
crashed my computer.
Thank You,
Ray
The question is as follows:
9. Present an example of a logic bug using pseudocode and explain your
answer. (10 points)
Temperature = 70
if (Temperature >69) and (Temperature < 100 )
THEN
openWindows;
Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.
2. Gentlemen, after reading your advise I had run the code in C++,
then stated it back in pseudocode. I suppose the programmer could
mistakenly use the "AND" && operator instead of the "OR" || operator
which I found the latter to run a loop which I couldn't end, not even
with a ctrl-c, and had to push the power button in to turn off my
computer (please keep that in mind). Also found that the temperatures
reflected would better reflect opening the windows and not closing
them.
Temperature = 70
if (Temperature >69) and (Temperature < 100 )
THEN
openWindows;
Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.
The code generated: numbered list 70-99
------------------------------------------------------------------------------------------------------------------------------------------------------
Temperature = 70
if (Temperature >69) or (Temperature < 100 )
THEN
openWindows;
Won't work because windows will stay closed due to temperature will
always be under 100 degrees the fault lies with the "or" "||" operator
which was used instead of the "and" (&&) operator.
The code generated: an infinite loop of never ending numbers that
crashed my computer.
Thank You,
Ray The code generated: numbered list
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Temperature = 70
if (Temperature >69) or (Temperature < 100 )
THEN
openWindows;
Won't work because windows will stay closed due to temperature will
always be under 100 degrees the fault lies with the "or" "||" operator
which was used instead of the "and" (&&) operator.
The code generated: an infinite loop of never ending numbers that
crashed my computer.
Thank You,
Ray