2.1-2.10 AP-Style MC Practices & Quizzes

¡Supera tus tareas y exámenes ahora con Quizwiz!

If the variable score has a value of 10 at the beginning of a program, which runs according to the following flowchart, what will the value of score be at the end? Add 3 to score | Multiply score by 2 | score >= 20 / \ yes no / \ Subtract 5 Add 10 | | score>= 15 Subtract 20 / \ / yes Divide by 2 / | Subtract 1 Add 3 a)10 b)11 c)13.5 d)10.5

a)10 -This isorrect. Beginning at the top of the flow chart we first add 3 to the value of score, which gives it a new value of 13. The next instruction calls for the value of score to be multiplied by 2, after which it will have a value of 26. This means that when it reaches the conditional block, because the value of score is greater than 20, the line marked yes proceeding to the left should be followed. The next instruction is to subtract 5 from the value of score, giving it a new value of 21. Following this another conditional block is reached. Because the value of score is greater than or equal to 15 the yes line to the left is followed, and the next block is run which causes 1 to be subtracted from the value of score, making this 20. We then return to the same decision block as before, meaning this process will repeat itself, subtracting 1 from score each time, until the value of score is 14, meaning the line marked no is followed at the selection block instead. Finally the value of score is divided by 2 to become 7, and then 3 is added to this value giving a final value of 10.

What will the final value of a be, after running the script below? set a^ to (0) { repeat 3 change a^ by (2) { repeat 4 change a^ by (1) } } say a for (2) seconds a)18 b)12 c)9 d)3

a)18 -This is correct. Each run of the inner loop causes the value of a to increase by 1 and the loop repeats 4 times. Therefore each run of the outer loop increases a by 2 and then by 1 for times: a total increase of 6. Since the outer loop runs 3 times in total, and a starts with a value of 0, at the end of the program it has a value of 18.

Consider the following: Total (0) Count (1) Repeat until (count>10) { next ← Input total ← total + next count ← count + 1 } average ← total / 10 Display average Which of the following values is displayed if the user inputs the following list of values for each prompt? 1 2 3 4 5 6 7 8 9 15 a)6 b)3 c)5 d)4

a)6 -This is correct. This program implements an algorithm for displaying the mean average of 10 inputted numbers. This works because the value of count begins at 1, and is increased by 1 on each iteration of the loop before the loop exits when count > 10. This means the code in the loop is run exactly 10 times. The variable total starts with a value of 0 and is increased by the value of the number inputted each time the loop is run. Once the loop is run 10 times, the value of total (which is now equal to the sum of the inputted numbers) is divided by 10 to give the variable average, which is then displayed. This means that the value displayed by the program given these inputs is (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 15)/10 = 60/10 = 6.

The software for an elevator uses a variable, called level, to track the floor number of the elevator's current position. When a person presses a button indicating that the elevator should rise to a higher floor, the following goUp procedure is invoked with the desired number of floors to climb provided as a parameter. ( Procedure goUp (floors) { Repeat floors times [ If (level<9) What is displayed if the elevator is currently on the 7th floor (level = 7) and the procedure goUp(3) is invoked? a)Level 8 Level 9 Cannot go up. Level 9 b)Level 7 Level 8 Level 9 c)Cannot go up. d)Level 8 Level 9 Level 10

a)Level 8 Level 9 Cannot go up. Level 9 -This is correct. The first time the REPEAT loop is run, the IF condition (level &lt; 9) is satisfied, so the value of level is increased by 1 to 8. The statement "Level 8" is then displayed at the end of this iteration. The second time, the IF condition is still satisfied so level is increased by 1 to 8, and the statement "Level 9" is displayed. The third time, the IF condition is no longer satisfied so the statement in the ELSE block will display "Cannot go up.". Then, as before, the statement "Level 9" will be displayed, since the value of level has not changed since the last run of the REPEAT block.

Consider the given code: 1 integer ← 22 2 lowtemp ← 0 3 4 IF(integer < 10) 5 { 6 lowtemp ← lowtemp - 5 7 } 8 ELSE 9 { 10 lowtemp ← lowtemp + 10 11 } 12 13 DISPLAY(lowtemp) What is the best description of the structure implied by line 4? a)Selection b)Sequencing c)Iteration d)Algorithm

a)Selection -This is correct. The IF statement on this line determines which lines of code in this program are run. This is clearly an example of selection: if the condition in the statement is met, then one block of code is "selected" and executed, if it is not met than another block is selected instead.

Consider the following code segment that is intended to accept two integers, x and y, as input, and then display "yes" if and only if x is greater than y and y is less than or equal to 20. Otherwise, it should display "no". x ← Input y ← Input If (x <= y) or (y>20) Display ("yes") Else Display ("no") Unfortunately, the above code does not perform as intended. Identify two different options that a programmer might choose, either of which will correct the code so that it performs as intended. Select two answers. a)Swap the two DISPLAY blocks (i.e., DISPLAY "yes" and DISPLAY "no" ) b)Change the condition in the IF block to be: IF (x > y) AND (y ≤ 20) c)Change the condition in the IF block to be: IF (x > y) OR (y ≤ 20) d)Swap the first two input/assignment blocks (i.e., x ← INPUT, y ← INPUT)

a)Swap the two DISPLAY blocks (i.e., DISPLAY "yes" and DISPLAY "no" ) b)Change the condition in the IF block to be: IF (x > y) AND (y ≤ 20)

A student developed a program that outputs the name of a fruit that begins with a letter, dependent upon the variable keyPressed, which stores the letter (from A to Z only) a user types on the keyboard. Below is a section of code from her program: -If ("key pressed" = A) Display apple Which of the following descriptions below would be a way that this student might have written the rest of her code so that it executes as intended? Select two answers. a)Use 26 IF blocks formatted similarly to the one above (changing the letters of the alphabet and fruits). b)Use 25 nested IF/ELSE blocks where the IF portion is formatted like the code segment above (changing the letters of the alphabet and fruits) and the else simply holding the next IF portion until the last ELSE, which displays a fruit that begins with Z. c)Use 26 IF/ELSE blocks where the IF portion is formatted like the code segment above (changing the letters of the alphabet and fruits) and each ELSE portion displays "You did not choose this letter". d)Take the above code and insert it into a REPEAT block that repeats 26 times.

a)Use 26 IF blocks formatted similarly to the one above (changing the letters of the alphabet and fruits). -This is correct. This is a simple solution, although not the most efficient: each IF statement will be checked in order and run if the letter matches and not run if it does not. This means only one out of the 26 statements will run. b)Use 25 nested IF/ELSE blocks where the IF portion is formatted like the code segment above (changing the letters of the alphabet and fruits) and the else simply holding the next IF portion until the last ELSE, which displays a fruit that begins with Z. -This is correct. Although this solution contains more lines of code than the other possibility, it is a little more efficient: each letter of the alphabet is checked and if it matches the correct fruit is displayed, and if not the corresponding ELSE section of the code is run to check the next letter. Once the correct statement is found the program will skip past all the other nested blocks and not bother checking the remaining letters in the alphabet. Should the final ELSE statement be reached this will not need to be checked since by process of elimination, keyPressed must be Z.

In a flowchart, a typical decision symbol has what type of output? a)boolean (true/false) b)None of these c)numerical d)text

a)boolean (true/false) -This is correct. A decision block allows one of two paths to be followed. To determine which path is followed, a boolean statement is usually written on the block, and one path is followed if this is true, another if it is false.

Sam and Emma are creating a multiplayer tic-tac-toe game. Below is a segment of their code that is used so that the Sprite on screen can tell the user whose turn it is. turn ← turn + 1 -If (condition 1) Display player 1's turn else Display player 2's turn Before each user's turn, this set of code is run. What would condition 1 need to be so that this part of the program runs correctly? The variable turn is initialized as 0 at the start and player 1 always goes first. a)turn MOD 2 = 1 b)turn > 0 c)turn = 1 d)turn MOD 2 =0

a)turn MOD 2 = 1 -This is correct. The variable turn is initialized as 0. When this block of code first runs, the first command increases the value of turn by 1. Therefore when the IF/ELSE block is first run the value of turn is 1. As this code is run before each users turn, when it is player 2's first turn the value of turn will again be increased by 1 to give a value of 2. Each subsequent turn the value is increased by 1, meaning that each time it is player 1's turn the value of turn is an odd number, and each time it is player 2's turn the value of turn is an even number. As the value of turn MOD 2 will be 1 whenever turn is odd, this condition should be in the place of condition 1 so that "Player 1's turn" is displayed whenever turn is odd.

Consider the following code segment that appears in the middle of a program. Which of the following can replace the missing statement in the REPEAT UNTIL block so that the user will be required to enter the correct password of "swordfish" before they can continue on with the rest of the program. a)userPassword = "swordfish" b)userPassword ← INPUT c)"swordfish" d)userPassword ≠ "swordfish"

a)userPassword = "swordfish" -This is correct. The first block in the program causes the value of the variable userPassword to be set to whatever the user inputs. The code in the REPEAT UNTIL block is run until the condition represented by missing statement is satisfied. As the code in this block makes the user enter the password again, we want this block to run until the correct password is entered. Therefore the condition represented by missing statement must be the one in which the password typed (stored in the variable userPassword) is equal to the password desired: "swordfish". This is represented in pseudocode as the the statement userPassword = "swordfish".

Consider the following code: REPEAT UNTIL (x mod 2 = 1) { x ← x + 3 } Assume that x is initially 6. How many times will the loop iterate? a)2 b)1 c)0 d)3

b)1 -This is correct. When the program is run, the condition x mod 2 = 1 is checked. As x mod 2 is defined as the remainder when x is divided by 2, it will have a value of 1 when x is even and 0 when x is odd. As the value of x is initially 6, when it is first checked the condition x mod 2 = 1 is false and the code in the loop is run. The code in the loop increases the value of x by 3 to make it 9. The condition x mod 2 = 1 is now checked again, and as it is now met, the loop is exited and the program terminates. In total therefore the loop iterates just once when the program is run.

Consider the given code fragment. Determine the output of the program fragment. m ← 2 REPEAT UNTIL(m > 500) { DISPLAY(m) m ← m + 2 } a)All even numbers 2 4 6 8 ... 498 b)All even numbers 2 4 6 8 ... 500 c)All odd numbers 1 3 5 7 ... 499 d)All numbers 0 1 2 3 ... 500

b)All even numbers 2 4 6 8 ... 500 -This is correct. When the program is run the value of m is initially set to 2. The program then enters a REPEAT UNTIL loop as the condition m > 500 is not met. The current value of m is displayed, then the value of m is increased by 2. At this point the condition m > 500 is checked again, and if it is still not satisfied the loop is run another time. This means the number 2 is initially displayed, followed by 2, 4, 6,... etc. When the value of m reaches 500, the condition m > 500 is still not met, so the program displays the number 500, and the value of m is increased to 502. At this point the condition m > 500 is checked again, and is finally met, so the loop is exited and the program terminates. Therefore the overall action of the program is to display the even numbers 2, 4, 6, 8, up to and including 500.

Which is NOT true about comments in programs? a)Commenting about program components helps in developing and maintaining programs. b)All published programs have their comments available. c)Commenting helps programmers develop and maintain programs to efficiently solve problems. d)Commenting helps while working collaboratively in programming environments.

b)All published programs have their comments available. -This is correct. This is a false statement, as the comments and program documentation for many programs may not be available if the program uses closed source code (i.e. the source code is not released for public consumption). You will learn more about open and closed code in unit 6.

Consider the following code segments designed to find the area of a triangle using the formula A = ½ bh. Program A v1 ← Input v2 ← Input v3 ← v1 * v2 / 2 Display (v3) Program B base ← Input height ← Input area ← base * height / 2 Display (area) Which of the following statements about the above programs is true? a)Program B will work as intended, but Program A will not work as intended. b)Both programs will work as intended, but Program B is more readable. c)Program A will work as intended, but Program B will not work as intended. d)Neither program will work as intended.

b)Both programs will work as intended, but Program B is more readable.

Which of the following is used in the instructions below to determine how the task of "having breakfast" will be performed? Dump cereal in bowl Pour milk in bowl Eat cereal and milk Place spoon and bowl in dishwasher I.Sequencing II.Selection III.Iteration a)II only b)I only c)I, II, and III d)I and III only

b)I only

The following lines of code can be used are part of a program which is designed to calculate the total a person will pay for a meal which costs mealTotal before a tax and tip is paid. The final amount should include tax on the original mealTotal at a percentage of taxRate and a tip at a percentage of tipRate on the original mealTotal. I.mealTotal ← mealTotal + tip + tax II.tip ← mealTotal * tipRate / 100 III.tax ← mealTotal * taxRate / 100 IV.DISPLAY mealTotal In which of the following orders could the lines I-IV be placed if the program is to run as intended? Select two answers. a)I, III, II, IV b)II, III, I, IV c)I, II, III, IV d)III, II, I, IV

b)II, III, I, IV d)III, II, I, IV

Using the flowchart below, what value when entered for Y will generate a mathematical error and prevent our flowchart from being completely executed? -y=y x 5 -y=y-15 -y/15 >- 2 / \ yes no y+2 y-4 a)0 b)None of these values will produce a mathematical error c)3 d)1

b)None of these values will produce a mathematical error 0This is correct. None of the operations in this flowchart have the potential to cause a mathematical error. Multiplication, addition and subtraction cannot by themselves cause mathematical errors, and the only division is by 15: only division by 0 causes a mathematical error.

Which of the following best describes the type of language used in the below algorithm? -Prompt user for number if number is greater than or equal to 0 Output "Positive" else Output "Negative" Repeat 4 times a)High-level language b)Pseudocode c)Natural language d)Low-level language

b)Pseudocode -This is correct. This language has a grammatical structure (syntax) which is not like that of a natural language such as written or spoken English. It is more precise and unambiguous than this. However there is no known computer programming language which is written in this way. This language is therefore best described as pseudocode.

The algorithm below is used to simulate the results of rolling a standard 6-sided die 5 times. Consider the goal of determining whether the simulation resulted in more results which were odd than results which were even. Step 1:Initialize the variables odd_counter and roll_counter to 0. Step 2:A variable dice_roll is randomly assigned an integer value between 1 and 6 inclusive. If dice_roll has a value of 1, 3 or 5, then odd_counter is incremented by 1. Step 3:Increment the value of roll_counter by 1.Step 4:Repeat steps 2 and 3 until roll_counter equals 5. Following the execution of the algorithm, which of the following expressions indicates that the simulation resulted in more results which were odd than results which were even? a)odd_counter>3 b)odd_counter>2 c)roll_counter>3 d)roll_counter>2

b)odd_counter>2 -This is correct. The variable odd_counter stores the number of times the dice showed an odd number. Since the dice is rolled 5 times, then a value of 3, 4 or 5 for this variable means there were more odd rolls than even rolls, in other words any of the possible integer values for odd_counter which are greater than 2. So the correct expression will

What will be displayed when the code segment below, using the variables a, b, and c, is run? a ← 0 b ← 1 c ← a a ← 2 b ← a DISPLAY (b) DISPLAY (c) a)1 0 b)0 0 c)2 0 d)2 2

c)2 0

Consider the code segment below. Line 1: IF (b ≠ 0) Line 2: { Line 3: a ← a/b Line 4: } Line 5: ELSE Line 6: { Line 7: a ← a*b Line 8: } Which of the following changes will NOT affect the results when the code segment is executed? a)Changing line 7 to a ← a/b b)Changing line 3 to a ← b c)Changing line 7 to a ← 0 d)Changing line 3 to b ← a/b

c)Changing line 7 to a ← 0 -This is correct. Line 7 is only run if the value of b is initially 0, and sets a to the value of a*b. Since multiplying any number by 0 gives an answer of 0, whenever this statement is run, a will be set to 0. Therefore replacing this with a ← 0 will not change the results of running this code.

Below is a block of code intended to navigate a robot through a grid of squares. For which of the following grids will the code correctly navigate the robot to a final destination of the grey square and then terminate? a)Grid 1 b)Grid 2 c)Grid 3 d)Grid 4

c)Grid 3 -This is correct. The program starts with a REPEAT UNTIL block with the condition CAN_MOVE (right), containing one instruction, MOVE_FORWARD (). This means that when the code is run the robot will initially check if it can move right, and if not will move forward. It will repeat this procedure until the first time it can move right, at which point the loop will exit and the final two commands, ROTATE_RIGHT () and MOVE_FORWARD () will run, causing the robot to turn 90 degrees right and move forward one square. For the grid in answer C, the robot cannot initially move right, therefore the robot moves forward in the direction it is facing (towards the left of the grid). It continues to do this until the first time it can move right, which is when it is in the leftmost white square of the grid, at which point it turns right and moves one square forward (up) into the grey square.

Consider a robot that is initially facing north in a 5-by-5 grid, as shown in the diagram below. A program segment has been written to move the robot to the upper-right corner where it should face west. Starting Position of Robot (facing north) Ending Position of Robot (facing west) The following program segment is intended to move a robot from the starting position to the ending position as shown above. However, the program segment does not work correctly. Line 1: MOVE_FORWARD () Line 2: MOVE_FORWARD () Line 3: IF(CAN_MOVE (right)) Line 4: { Line 5: MOVE_FORWARD () Line 6: MOVE_FORWARD () Line 7: ROTATE_RIGHT () Line 8: } Line 9: ROTATE_LEFT () Line 10: ROTATE_LEFT () Which 2 lines of code in the segment above must be switched in order for the program to correctly move a robot from the starting position to the ending position? Select two answers. a)Line 2 b)Line 9 c)Line 7 d)Line 5

c)Line 7 -This is correct. The IF block in this code checks whether the robot can turn right, but then attempts to move the robot forwards twice before this ROTATE_RIGHT command is reached. If this line of code was earlier then the robot would move to face the direction in which it has just checked if it is possible to move. d)Line 5 -This is correct. Currently when this point in the program is reached the robot attempts to move off the top of the grid. Instead a rotate statement should be here to change the direction the robot is facing.

What is displayed as a result of running the following program? a ← 6 b ← 11 IF (a = b) { DISPLAY ("January") } ELSE { IF (a > b) { DISPLAY ("February") } ELSE { IF (a > 0) { DISPLAY ("March") } ELSE { DISPLAY ("April") } } } a)February b)January c)March d)April

c)March -This is correct. The program initially sets the values of a and b to 6 and 11 respectively. The first IF statement encountered has a condition a = b, and as this is not true the code in the IF block is not run, and the corresponding ELSE block is run instead. The first line in this block is another IF statement, this time with condition a &gt; b, and as this is not true the code in the IF block is also not run, and the corresponding ELSE block is run instead. The first line in this block is another IF statement, this time with condition a &gt; 0. As this statement is true, the code in the IF block is run, displaying "March".

The following is the only script attached to a sprite in Scratch. Which of the following best describes what will be drawn on the screen when the green flag is clicked (you may assume the sprite starts in the center of the screen with all default settings)? -when flag clicked { -repeat 4 move 100 steps turn 90 degrees } a)A triangle b)A square c)Nothing will be drawn; the program lacks a pen down command. d)A circle

c)Nothing will be drawn; the program lacks a pen down command. -This is correct. Sprites moving in Scratch do not leave any trace by default. When the pen extension is added, this can be changed, but the command pen down must be run by the sprite for this to happen.

Consider the following code: n ← 4 x ← -2.5 IF(n < 3) { DISPLAY("Team A") } ELSE { IF(n < 2) { DISPLAY("Team B") } ELSE { IF(x > -2) { DISPLAY("Team C") } ELSE { DISPLAY("Team D") } } } Which of the following is the output of the code? a)Team C b)Team B c)Team D d)Team A

c)Team D -This is correct. When the code is run, the value of n is set to 4, and the value of x is set to -2.5. The condition for the first IF statement is then checked (n < 3), and as this is not true (since n = 4), the code in the IF block is not run. As the code for this IF block did not run, instead the code in the corresponding ELSE block is run. Immediately a second IF statement with condition n < 2, is checked, and as the condition is once again not satisfied the code in the IF block is not run and the corresponding ELSE block is run instead. A final IF statement with condition x > -2, is checked, and as x = -2.5 the condition is once again not satisfied. The code in the IF block is not run and the corresponding ELSE block is run containing the statement DISPLAY("Team D"). Therefore the result of running the code is that "Team D" is displayed.

Which of the following best describes the output of the following code segment? Repeat (random 1,10) times { Display "Hi" } a)The word HI could be displayed 1, 2, 3, 4, 5, 6, 7, 8, or 9 times b)The word HI could be displayed 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10 times c)The word HI could be displayed 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10 times b)The word HI could be displayed 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9 times

c)The word HI could be displayed 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10 times -This is correct. In the CollegeBoard pseudocode, the command RANDOM(A, B) generates a random integer which is between a and b inclusive. This means that RANDOM(1, 10) can return any integer between 1 and 10, including 1 and 10. Since the block is repeated a number of times equal to RANDOM(1, 10), the command in the block DISPLAY ("Hi") is repeated a number of times which could be any integer between 1 and 10 inclusive, i.e. 1, 2, 3, 4, 5, 6, 7, 8, 9 or 10 times.

What should replace <missing statement> in the following code be if we want this code to repeat until the variable a is greater than 10? a ← 0 REPEAT UNTIL (<missing statement>) { a ← a + 1 } a)a = 10 b)a > b c)a > 10 d)10 > a

c)a > 10 -This is correct. The symbol > is interpreted as "greater than" both in general and in the CollegeBoard Pseudocode. Therefore the condition a > 10 is true when the value of the variable a is greater than 10. This is the condition for the loop to exit.

The block of code below is supposed to display "Multiple of 5" if the positive number value is in fact a multiple of 5. If (missing condition) Display (multiple of 5) Else Display (Incorrect) a) (value MOD 1) = 5 b) (value MOD 0) = 5 c) (value MOD 5) = 1 d) (value MOD 5) = 0

d) (value MOD 5) = 0 -This is correct. The modulo function works in the following way: For the integers k and n, the command k MOD n computes the remainder when k is divided by n. Therefore, if value is a multiple of 5, value MOD 5 will return 0. As the string "Multiple of 5" is displayed whenever the expression missing condition is true, the missing condition should be (value MOD 5) = 0.

x ← 0 a ← 3 k ← 4 REPEAT a TIMES { REPEAT k TIMES { x ← x + a } x ← x * (-1) } DISPLAY x When the code above is run, what will be the final value of the variable x, displayed at the end of the program? a)9 b)-9 c)12 d)-12

d)-12 -This is correct. The outer loop is run a total of 4 times as a = 4. On each run the inner loop is run 3 times as k = 3, increasing the value of x by a = 4 each time. In effect, this inner loop increases the value of x by 12 and then exits. The last instruction in the outer loop multiplies the current value of x by -1. The value of x is initially 0, then the first run of the outer loop increases this to 12 and multiplies it by -1, giving a value of -12. On the next run of the loop, this is increased to 0 and again multiplied by -1, which leaves it with a value of 0. On the final run of the loop, x is once again increased to 12 and multiplied by -1, giving a final value of x = -12.

Consider the given code using variables a, b, and c. What will be the output of this code? a ← 2 b ← 6 c ← 12 a ← b b ← c DISPLAY(a) DISPLAY(c) a)2 12 b)2 6 c)12 12 d)6 12

d)6 12 -This is correct. When the code is run, the initial value of a is set to 2, the initial value of b is set to 6, and the initial value of c is set to 12. The value of a is then set to the current value of b, which is 6, then the value of b is set to the current value of c, which is 12. At this point the value of a is now 6, and the value of both b and c is 12. The final two lines display the value of a, followed by the value of c. This results in the number 6, followed by the number 12 being displayed.

This question references a robot in a grid of squares. The robot is represented by the triangle in the bottom left-hand corner and is facing toward the top. Based on the following program, what would the robot's final position be? MOVE_FORWARD MOVE_FORWARD IF (CAN_MOVE(right)) { ROTATE_RIGHT MOVE_FORWARD MOVE_FORWARD } IF (CAN_MOVE(left)) { ROTATE_LEFT MOVE_FORWARD ROTATE_LEFT } a)Grid 1 b)Grid 2) c)Grid 3 d)Grid 4

d)Grid 4 -This is correct. The initial two commands move the robot two squares towards the top of the grid. Since the robot has a free space to its right, the following IF block is run, rotating the robot 90 degrees right and moving 2 squares towards the right of the grid. At this point the robot is in the central square facing the right of the grid. As the robot has a free square to its left the robot rotates left 90 degrees and moves one square towards the top of the grid before rotating left again to face the left side of the grid in the position shown.

This is a section of code taken from a larger program. If (value ≠ 4) Display (missing output 1) Else Display (missing output 2) What outputs would be the best choice to substitute in for "missing output 1" and "missing output 2", based on the condition? a)missing output 1: value does not equal 4 missing output 2: value is greater than 4 b)missing output 1: value does not equal 4 missing output 2: value does not equal 4 c)missing output 1: value is equal to 4 missing output 2: value does not equal 4 d)missing output 1: value does not equal 4 missing output 2: value is equal to 4D

d)missing output 1: value does not equal 4 missing output 2: value is equal to 4 -This is correct. The symbol ≠ means "does not equal to" both in general and in the CollegeBoard pseudocode. Therefore the expression value ≠ 4 will be false when the value of the variable value is 4, and will be true when the value of the variable value is any number other than 4. When this expression is true (i.e. value is any number other than44) the IF statement causes the string "missing output 1" to be displayed, so this should therefore be "value does not equal 4". When the expression is false, "missing output 2" is displayed, and as value must be 4 this string should be "value is equal to 4".


Conjuntos de estudio relacionados

Human Sexuality: Making Informed Decisions Exam 1

View Set

MTA 98-361 Ch.5 Understanding Desktop Applications Questions

View Set

DH244 interpretation of dental caries

View Set

Listing and Selling HUD Homes (h)

View Set

Chapter 6 life span and development

View Set

Ultimate Study Set MGMT 4500 Exam 1

View Set