Asked by joe

The AP Exam does not use for loops and while loops, but rather REPEAT or REPEAT UNTIL commands as shown below.

REPEAT n TIMES
{
<block of statements>
}

REPEAT UNTIL(condition)
{
<block of statements>
}
In the procedure Mystery written below, the input to value is always a positive number

PROCEDURE Mystery ()
{
value ← ??
number ← value

REPEAT UNTIL (number = 0)
{
value ← value * -1
number ← number - 1
}

IF (value > 0)
{
RETURN (false)
}
ELSE
{
RETURN (true)
}
}
Which of the following best describes the result of running the Mystery procedure?



The result will always be true for any initial value of value


The result will be false whenever the initial value of value is even


The result will always be false for any initial value of value


The result will be false whenever the initial value of value is odd

Answers

There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!

Related Questions