For the given pseudocode, which XXX and YYY will output the sum of the input integers
(stopping when -1 is input)? Choices are in the form XXX / YYY.
val = Get next input
XXX
While val is not -1
YYY
val = Get next input
Put sum to output
sum = val / sum = val
sum = val / sum = sum + val
sum = 0 / sum = sum + val
sum = 0 / sum = val correct answers sum = 0 / sum = sum + val
For the given pseudocode, which XXX and YYY will output the number of times that 10 is input
(stopping when 0 is input)? Choices are in the form XXX / YYY.
count = 0
val = Get next input
While val is not 0
If val == 10
XXX
Else
YYY
val = Get next input
Put count to output
count = count + 1 / count = 0
count = count + 1 / (nothing)
count = count + val / (nothing)
count = count + val / count = 0 correct answers count = count + 1 / (nothing)
For the given pseudocode, which XXX and YYY will output the smallest non-negative input
(stopping when a negative value is input)? Choices are in the form XXX / YYY.
min = 0
val = Get next input
min = val
While val is not negative
If XXX
YYY
val = Get next input
Put min to output
val > 0 / min = val
min < val / val = min
, val > min / val = min
val < min / min = val correct answers val < min / min = val
Which input value causes "Goodbye" to be output next?
int x;
x = scnr.nextInt();
while (x >= 0) {
// Do something
x = scnr.nextInt();
}
System.out.println("Goodbye");
-1
0
1
No such value correct answers -1
Which input for char c causes "Done" to be output next?
c = 'y';
while (c = 'y') {
// Do something
System.out.println("Enter y to continue, n to quit: ");
// Get c from input}
System.out.println("Done");
'y' only
'n' only
Any value other than 'y'
No such value (error comparing c and 'y') correct answers No such value (error comparing c and
'y')
What is the output, if the input is 3 2 1 0?
x = scnr.nextInt();
while (x > 0) {System.out.print(2 * x + " ");
}
6
642
6420
6 6 6 6 6 ... (infinite loop) correct answers 6 6 6 6 6 ... (infinite loop)
Which XXX and YYY will loop as long as the input is an integer less than 100? Choices are in
the form XXX / YYY.
w = scnr.nextInt();
while (XXX) {
// Do something