Programming Fundamentals — One Question at a Time

Programming Fundamentals — One Question at a Time

Practise 150 Programming Fundamentals multiple-choice questions covering algorithms, expressions, control structures, loops, arrays, functions, recursion and file handling. Work through one question at a time, check the correct answer with an explanation, and select Next Question to continue. This is self-paced practice without automatic scoring.

Before you practise: Read Programming Fundamentals study material and examples. You can also browse all 1,576 interactive MCQs.

Practice Set 1 · Question 1 of 150

Question 1. What is an algorithm?

  1. A finite, well-defined sequence of steps to solve a problem
  2. A computer’s physical memory
  3. A type of network cable
  4. A programming-language logo
Show Answer and Explanation

Correct answer: A. A finite, well-defined sequence of steps to solve a problem

An algorithm describes a clear procedure that terminates after finitely many steps.

Next Question →

Practice Set 1 · Question 2 of 150

Question 2. Which property means that an algorithm eventually stops?

  1. Ambiguity
  2. Finiteness
  3. Recursion
  4. Portability
Show Answer and Explanation

Correct answer: B. Finiteness

Finiteness requires an algorithm to terminate after a limited number of steps.

Next Question →

Practice Set 1 · Question 3 of 150

Question 3. Which sequence best describes a common problem-solving process?

  1. Code → guess → test nothing
  2. Understand → design → implement → test
  3. Test → delete → guess → publish
  4. Compile → skip design → stop
Show Answer and Explanation

Correct answer: B. Understand → design → implement → test

A sound workflow begins by understanding requirements, designing an algorithm, implementing it and testing.

Next Question →

Practice Set 1 · Question 4 of 150

Question 4. What is the primary function of a compiler?

  1. Convert source code into a target representation such as machine code
  2. Store every file permanently
  3. Control the computer monitor
  4. Draw a flowchart automatically
Show Answer and Explanation

Correct answer: A. Convert source code into a target representation such as machine code

A compiler translates source code into another form, commonly object or machine code.

Next Question →

Practice Set 1 · Question 5 of 150

Question 5. What does a linker commonly do?

  1. Combine object files and resolve external references
  2. Measure monitor brightness
  3. Choose variable names automatically
  4. Execute only comments
Show Answer and Explanation

Correct answer: A. Combine object files and resolve external references

Linkers combine separately compiled modules and connect referenced symbols and libraries.

Next Question →

Practice Set 1 · Question 6 of 150

Question 6. In the classic von Neumann model, where are instructions and data stored?

  1. Only in the CPU’s arithmetic unit
  2. In the same main memory
  3. On separate keyboards
  4. Only on output devices
Show Answer and Explanation

Correct answer: B. In the same main memory

The stored-program model places instructions and data in addressable memory.

Next Question →

Practice Set 1 · Question 7 of 150

Question 7. Which of these is a Boolean value?

  1. -3.5
  2. “hello”
  3. TRUE
  4. 42
Show Answer and Explanation

Correct answer: C. TRUE

A Boolean value is either true or false.

Next Question →

Practice Set 1 · Question 8 of 150

Question 8. If x ← 7 and y ← 3, what is x + 2 × y?

  1. 27
  2. 13
  3. 21
  4. 17
Show Answer and Explanation

Correct answer: B. 13

Multiplication comes first: 2 × 3 = 6, so 7 + 6 = 13.

Next Question →

Practice Set 1 · Question 9 of 150

Question 9. With integer division defined as discarding the remainder for nonnegative integers, what is 17 DIV 5?

  1. 2
  2. 3
  3. 3.4
  4. 4
Show Answer and Explanation

Correct answer: B. 3

17 = 5 × 3 + 2, so the integer quotient is 3.

Next Question →

Practice Set 1 · Question 10 of 150

Question 10. What is 17 MOD 5?

  1. 2
  2. 3
  3. 5
  4. 12
Show Answer and Explanation

Correct answer: A. 2

MOD returns the remainder; dividing 17 by 5 leaves remainder 2.

Continue to Practice Set 2

Practice Set 2 · Question 11 of 150

Question 11. If a ← 4, then a ← a + 6, what is the final value of a?

  1. 4
  2. 6
  3. 10
  4. 24
Show Answer and Explanation

Correct answer: C. 10

The right-hand expression uses the old value: 4 + 6 = 10, then assigns 10 to a.

Next Question →

Practice Set 2 · Question 12 of 150

Question 12. Which expression is TRUE when x = 8?

  1. x < 5
  2. x = 3
  3. x > 6 AND x < 10
  4. x > 10 OR x < 0
Show Answer and Explanation

Correct answer: C. x > 6 AND x < 10

8 is greater than 6 and less than 10, so both conditions are true.

Next Question →

Practice Set 2 · Question 13 of 150

Question 13. What is the purpose of an IF statement?

  1. Repeat code forever
  2. Select actions based on a condition
  3. Declare a fixed array length
  4. Merge object files
Show Answer and Explanation

Correct answer: B. Select actions based on a condition

An IF statement executes a branch according to a Boolean condition.

Next Question →

Practice Set 2 · Question 14 of 150

Question 14. If score = 49, what does IF score ≥ 50 THEN print(“Pass”) ELSE print(“Retry”) output?

  1. Pass
  2. Retry
  3. 49
  4. Nothing
Show Answer and Explanation

Correct answer: B. Retry

49 does not meet the threshold of 50, so the ELSE branch prints Retry.

Next Question →

Practice Set 2 · Question 15 of 150

Question 15. What does a WHILE loop check before each iteration?

  1. Only the filename
  2. Its loop condition
  3. The number of CPU cores
  4. The program’s author
Show Answer and Explanation

Correct answer: B. Its loop condition

A WHILE loop evaluates its condition before executing each iteration.

Next Question →

Practice Set 2 · Question 16 of 150

Question 16. In pseudocode, x ← 1; WHILE x < 5: x ← x + 2. What is x after the loop?

  1. 3
  2. 4
  3. 5
  4. 7
Show Answer and Explanation

Correct answer: C. 5

Starting at 1, x becomes 3 and then 5. Since 5 < 5 is false, the loop stops.

Next Question →

Practice Set 2 · Question 17 of 150

Question 17. How many times is the body executed for FOR i ← 1 TO 4 (inclusive)?

  1. 3
  2. 4
  3. 5
  4. 0
Show Answer and Explanation

Correct answer: B. 4

The index takes the values 1, 2, 3 and 4, yielding four iterations.

Next Question →

Practice Set 2 · Question 18 of 150

Question 18. What condition most directly risks an infinite WHILE loop?

  1. The condition always becomes false
  2. The condition remains true and there is no other exit
  3. A variable has a short name
  4. The program prints a number
Show Answer and Explanation

Correct answer: B. The condition remains true and there is no other exit

If the condition never becomes false and no exit occurs, the loop cannot terminate.

Next Question →

Practice Set 2 · Question 19 of 150

Question 19. For zero-based array A = [5, 9, 2, 8], what is A[2]?

  1. 5
  2. 9
  3. 2
  4. 8
Show Answer and Explanation

Correct answer: C. 2

Zero-based positions are 0, 1, 2 and 3; A[2] is the third value, 2.

Next Question →

Practice Set 2 · Question 20 of 150

Question 20. Which is the main benefit of placing repeated logic in a function?

  1. It always eliminates memory use
  2. It improves reuse and organisation
  3. It prevents input
  4. It makes algorithms mathematically incorrect
Show Answer and Explanation

Correct answer: B. It improves reuse and organisation

Functions package reusable behaviour and help structure programs into manageable parts.

Continue to Practice Set 3

Practice Set 3 · Question 21 of 150

Question 21. Suppose square(n) returns n × n. What is square(6)?

  1. 12
  2. 18
  3. 36
  4. 64
Show Answer and Explanation

Correct answer: C. 36

Substituting n = 6 gives 6 × 6 = 36.

Next Question →

Practice Set 3 · Question 22 of 150

Question 22. In a two-dimensional array, which pair identifies an element?

  1. Filename and extension
  2. Row and column indices
  3. Password and username
  4. Compiler and linker
Show Answer and Explanation

Correct answer: B. Row and column indices

A two-dimensional array is indexed using two positions, commonly row and column.

Next Question →

Practice Set 3 · Question 23 of 150

Question 23. If a function returns a value, what does RETURN normally do?

  1. Exit the function while providing that value to its caller
  2. Delete all variables in the program
  3. Start an unrelated process
  4. Convert a string to a file
Show Answer and Explanation

Correct answer: A. Exit the function while providing that value to its caller

RETURN transfers control back to the caller and supplies the result.

Next Question →

Practice Set 3 · Question 24 of 150

Question 24. What is a string in introductory programming?

  1. A sequence of characters
  2. A processor register
  3. A network router
  4. An arithmetic operator only
Show Answer and Explanation

Correct answer: A. A sequence of characters

A string represents text as a sequence of characters.

Next Question →

Practice Set 3 · Question 25 of 150

Question 25. Which operation typically obtains data from a stored file?

  1. File read
  2. Screen brightness adjustment
  3. Variable renaming
  4. Code indentation
Show Answer and Explanation

Correct answer: A. File read

Reading a file retrieves its stored bytes or text for processing.

Next Question →

Practice Set 3 · Question 26 of 150

Question 26. What is dynamic memory allocation?

  1. Allocating memory during program execution as needed
  2. Printing an integer
  3. Changing the keyboard layout
  4. Converting HTML into a PDF
Show Answer and Explanation

Correct answer: A. Allocating memory during program execution as needed

Dynamic allocation requests memory while a program is running rather than relying solely on predetermined storage.

Next Question →

Practice Set 3 · Question 27 of 150

Question 27. What does a pointer generally store in a language such as C?

  1. A memory address
  2. A compressed image only
  3. The number of compiler warnings
  4. An entire operating system
Show Answer and Explanation

Correct answer: A. A memory address

A pointer holds an address that can identify a memory location.

Next Question →

Practice Set 3 · Question 28 of 150

Question 28. Which operation joins the strings “data” and “base” into “database”?

  1. Subtraction
  2. Concatenation
  3. Integer division
  4. Modulus
Show Answer and Explanation

Correct answer: B. Concatenation

String concatenation combines two sequences of characters end to end.

Next Question →

Practice Set 3 · Question 29 of 150

Question 29. Why is closing a file after use generally important?

  1. It helps release resources and flush buffered data as appropriate
  2. It changes all integers to strings
  3. It guarantees perfect security
  4. It erases the file automatically
Show Answer and Explanation

Correct answer: A. It helps release resources and flush buffered data as appropriate

Closing releases handles and may ensure pending writes are committed through the program’s I/O buffers.

Next Question →

Practice Set 3 · Question 30 of 150

Question 30. A program reads one line from a text file. Which case must robust code handle?

  1. The end of the file
  2. The speed of light
  3. The number of display pixels
  4. Only the variable’s spelling
Show Answer and Explanation

Correct answer: A. The end of the file

End-of-file is a normal condition; code should detect it instead of assuming lines always remain.

Continue to Practice Set 4

Practice Set 4 · Question 31 of 150

Question 31. What does binary search require?

  1. Sorted search data
  2. Only unique values
  3. A linked list
  4. No comparisons
Show Answer and Explanation

Correct answer: A. Sorted search data

The ordering permits half of the current search interval to be discarded.

Next Question →

Practice Set 4 · Question 32 of 150

Question 32. Starting n = 1, repeatedly double n while n < 20. What is final n?

  1. 16
  2. 20
  3. 32
  4. 64
Show Answer and Explanation

Correct answer: C. 32

1, 2, 4, 8, 16, 32; at 32 the condition is false.

Next Question →

Practice Set 4 · Question 33 of 150

Question 33. Which flowchart symbol commonly means a decision?

  1. Rectangle
  2. Diamond
  3. Oval
  4. Parallelogram
Show Answer and Explanation

Correct answer: B. Diamond

A diamond denotes branching on a condition.

Next Question →

Practice Set 4 · Question 34 of 150

Question 34. Which test case probes an empty-array boundary?

  1. Length 10
  2. Length 0
  3. Length 100
  4. Length 2
Show Answer and Explanation

Correct answer: B. Length 0

A zero-length input checks handling of no elements.

Next Question →

Practice Set 4 · Question 35 of 150

Question 35. For x=5 and y=9, evaluate NOT(x > 7 OR y < 4).

  1. TRUE
  2. FALSE
  3. 5
  4. 9
Show Answer and Explanation

Correct answer: A. TRUE

Both comparisons are false; NOT(false OR false) is true.

Next Question →

Practice Set 4 · Question 36 of 150

Question 36. For nonnegative integer arithmetic, evaluate (10 MOD 4) × (10 DIV 4).

  1. 2
  2. 4
  3. 6
  4. 8
Show Answer and Explanation

Correct answer: B. 4

The remainder and integer quotient are both 2; product is 4.

Next Question →

Practice Set 4 · Question 37 of 150

Question 37. Evaluate 3 + 12 / 4 × 2 using usual precedence and left associativity.

  1. 7
  2. 9
  3. 12
  4. 15
Show Answer and Explanation

Correct answer: B. 9

12 / 4 = 3; 3 × 2 = 6; 3 + 6 = 9.

Next Question →

Practice Set 4 · Question 38 of 150

Question 38. NOT(A AND B) is equivalent to which expression?

  1. NOT A AND NOT B
  2. A OR B
  3. NOT A OR NOT B
  4. A AND NOT B
Show Answer and Explanation

Correct answer: C. NOT A OR NOT B

De Morgan’s law converts the negated conjunction to a disjunction of negations.

Next Question →

Practice Set 4 · Question 39 of 150

Question 39. For i from 2 to 6 inclusive with step 2, sum all i. What is the sum?

  1. 6
  2. 9
  3. 12
  4. 20
Show Answer and Explanation

Correct answer: C. 12

The visited values are 2, 4, 6; their sum is 12.

Next Question →

Practice Set 4 · Question 40 of 150

Question 40. If a WHILE condition is initially false, how many times is its body executed?

  1. 0
  2. 1
  3. 2
  4. Infinitely
Show Answer and Explanation

Correct answer: A. 0

WHILE checks its condition before entering the body.

Continue to Practice Set 5

Practice Set 5 · Question 41 of 150

Question 41. What are the valid zero-based indexes of an array of length n > 0?

  1. 1 through n
  2. 0 through n
  3. 0 through n−1
  4. Only n
Show Answer and Explanation

Correct answer: C. 0 through n−1

The first index is 0 and the last valid index is n−1.

Next Question →

Practice Set 5 · Question 42 of 150

Question 42. x ← 12; WHILE x > 3: x ← x DIV 2. What is final x?

  1. 1
  2. 2
  3. 3
  4. 6
Show Answer and Explanation

Correct answer: C. 3

12 changes to 6 and then 3; the loop then stops.

Next Question →

Practice Set 5 · Question 43 of 150

Question 43. For B=[4,7,1,9,2] with zero-based indexing, what is B[1]+B[4]?

  1. 6
  2. 8
  3. 9
  4. 11
Show Answer and Explanation

Correct answer: C. 9

7 + 2 = 9.

Next Question →

Practice Set 5 · Question 44 of 150

Question 44. How many elements are in a rectangular 3-by-4 array?

  1. 7
  2. 9
  3. 12
  4. 16
Show Answer and Explanation

Correct answer: C. 12

Multiply rows by columns: 3 × 4 = 12.

Next Question →

Practice Set 5 · Question 45 of 150

Question 45. What is the character at index 3 in the string LEVEL (zero-based)?

  1. L
  2. E
  3. V
  4. Out of range
Show Answer and Explanation

Correct answer: B. E

Positions 0–4 are L, E, V, E, L.

Next Question →

Practice Set 5 · Question 46 of 150

Question 46. What is typical indexed-access time for a contiguous array A[k]?

  1. O(1)
  2. O(n)
  3. O(n²)
  4. O(log n)
Show Answer and Explanation

Correct answer: A. O(1)

The index determines the element address in constant time under the standard array model.

Next Question →

Practice Set 5 · Question 47 of 150

Question 47. What is needed for terminating recursive computation on valid inputs?

  1. A base case and progress toward it
  2. Only global variables
  3. Two loops
  4. A file
Show Answer and Explanation

Correct answer: A. A base case and progress toward it

The recursion must reach a case that does not make another recursive call.

Next Question →

Practice Set 5 · Question 48 of 150

Question 48. Given factorial(0)=1 and factorial(n)=n×factorial(n−1), what is factorial(4)?

  1. 10
  2. 16
  3. 24
  4. 120
Show Answer and Explanation

Correct answer: C. 24

4×3×2×1 = 24.

Next Question →

Practice Set 5 · Question 49 of 150

Question 49. A function modifies a pass-by-value integer parameter. What happens to the caller’s variable?

  1. Always changes
  2. Remains unchanged
  3. Becomes 0
  4. Is deleted
Show Answer and Explanation

Correct answer: B. Remains unchanged

Pass-by-value operates on a separate local value.

Next Question →

Practice Set 5 · Question 50 of 150

Question 50. The call stack commonly tracks which information?

  1. Active calls and return information
  2. Only images
  3. Files on disk
  4. Network cables
Show Answer and Explanation

Correct answer: A. Active calls and return information

Each active invocation commonly has a stack frame storing return and local state information.

Continue to Practice Set 6

Practice Set 6 · Question 51 of 150

Question 51. Unreleased dynamic allocations in a manually managed environment may cause what?

  1. Memory leak
  2. Syntax highlighting
  3. Faster code
  4. Only arithmetic overflow
Show Answer and Explanation

Correct answer: A. Memory leak

Memory that is never freed can accumulate.

Next Question →

Practice Set 6 · Question 52 of 150

Question 52. How should a program handle reading past end-of-file?

  1. Check for EOF or read failure
  2. Assume data exists
  3. Restart the OS
  4. Delete the file
Show Answer and Explanation

Correct answer: A. Check for EOF or read failure

Read results must be checked before processing.

Next Question →

Practice Set 6 · Question 53 of 150

Question 53. Which file mode normally adds new data to the end of existing content?

  1. Read
  2. Append
  3. Write-truncate
  4. Binary-only
Show Answer and Explanation

Correct answer: B. Append

Append writes at the end rather than replacing earlier data.

Next Question →

Practice Set 6 · Question 54 of 150

Question 54. What is a dangling pointer?

  1. A pointer to an object whose lifetime ended
  2. A valid pointer to the first array element
  3. A text string
  4. A pointer holding the count of warnings
Show Answer and Explanation

Correct answer: A. A pointer to an object whose lifetime ended

References to objects that no longer exist are invalid.

Next Question →

Practice Set 6 · Question 55 of 150

Question 55. A loop visits every element of an array of size n exactly once. What is its time complexity?

  1. O(1)
  2. O(log n)
  3. O(n)
  4. O(n²)
Show Answer and Explanation

Correct answer: C. O(n)

There are n visits with constant work each, so total time is O(n).

Next Question →

Practice Set 6 · Question 56 of 150

Question 56. Two nested loops each execute n times, with constant work inside. What is their complexity?

  1. O(n²)
  2. O(n)
  3. O(log n)
  4. O(1)
Show Answer and Explanation

Correct answer: A. O(n²)

There are n × n iterations, so the running time is O(n²).

Next Question →

Practice Set 6 · Question 57 of 150

Question 57. Binary search on a sorted array of 64 items requires at most how many comparisons to find an item or establish absence?

  1. 5
  2. 6
  3. 7
  4. 64
Show Answer and Explanation

Correct answer: C. 7

Successive search intervals have sizes at most 64, 32, 16, 8, 4, 2 and 1, giving at most seven comparisons.

Next Question →

Practice Set 6 · Question 58 of 150

Question 58. An algorithm uses two integer variables and no input-sized auxiliary data. What is its auxiliary space complexity?

  1. O(1)
  2. O(n)
  3. O(n²)
  4. O(2ⁿ)
Show Answer and Explanation

Correct answer: A. O(1)

A constant number of scalar variables needs constant auxiliary space.

Next Question →

Practice Set 6 · Question 59 of 150

Question 59. Given x ← 2; y ← 5; x ← x + y; y ← x − y; x ← x − y, what are (x, y)?

  1. (2, 5)
  2. (5, 2)
  3. (7, 5)
  4. (5, 7)
Show Answer and Explanation

Correct answer: B. (5, 2)

The assignments give x=7; y=2; x=5. Thus the final pair is (5,2).

Next Question →

Practice Set 6 · Question 60 of 150

Question 60. What is x after x ← 0; FOR i ← 1 TO 4 inclusive: x ← x + i × i?

  1. 10
  2. 20
  3. 30
  4. 40
Show Answer and Explanation

Correct answer: C. 30

The sum of squares is 1 + 4 + 9 + 16 = 30.

Continue to Practice Set 7

Practice Set 7 · Question 61 of 150

Question 61. Let a ← 7. IF a MOD 2 = 0 THEN a ← a DIV 2 ELSE a ← 3 × a + 1. What is a?

  1. 4
  2. 11
  3. 21
  4. 22
Show Answer and Explanation

Correct answer: D. 22

Since 7 is odd, the ELSE branch assigns 3×7+1 = 22.

Next Question →

Practice Set 7 · Question 62 of 150

Question 62. For n ← 18; count ← 0; WHILE n > 1: n ← n DIV 2; count ← count + 1, what is count?

  1. 3
  2. 4
  3. 5
  4. 6
Show Answer and Explanation

Correct answer: B. 4

The values of n after iterations are 9, 4, 2, 1; four iterations occur.

Next Question →

Practice Set 7 · Question 63 of 150

Question 63. Given A = [3, 1, 4, 1, 5], what is the sum of A[0], A[2] and A[4] with zero-based indexing?

  1. 8
  2. 9
  3. 12
  4. 13
Show Answer and Explanation

Correct answer: C. 12

The indexed values are 3, 4 and 5; their sum is 12.

Next Question →

Practice Set 7 · Question 64 of 150

Question 64. What is the result of reversing the array [2, 7, 9, 4]?

  1. [4, 9, 7, 2]
  2. [2, 4, 7, 9]
  3. [9, 7, 4, 2]
  4. [4, 7, 9, 2]
Show Answer and Explanation

Correct answer: A. [4, 9, 7, 2]

Reversing swaps the first and last positions and the two middle positions.

Next Question →

Practice Set 7 · Question 65 of 150

Question 65. For a 4-row, 3-column array, how many elements are there?

  1. 7
  2. 12
  3. 16
  4. 24
Show Answer and Explanation

Correct answer: B. 12

The array contains 4 × 3 = 12 elements.

Next Question →

Practice Set 7 · Question 66 of 150

Question 66. Which search method can work on an unsorted array without preprocessing?

  1. Binary search as normally defined
  2. Linear search
  3. Interpolation search only
  4. None
Show Answer and Explanation

Correct answer: B. Linear search

Linear search compares each candidate in turn and does not require sorting.

Next Question →

Practice Set 7 · Question 67 of 150

Question 67. If f(x) returns 2x + 3, what is f(f(1))?

  1. 5
  2. 10
  3. 13
  4. 16
Show Answer and Explanation

Correct answer: C. 13

First f(1)=5, then f(5)=2×5+3=13.

Next Question →

Practice Set 7 · Question 68 of 150

Question 68. Using f(0)=0, f(1)=1, and f(n)=f(n−1)+f(n−2) for n≥2, what is f(6)?

  1. 5
  2. 8
  3. 13
  4. 21
Show Answer and Explanation

Correct answer: B. 8

The terms from f(0) to f(6) are 0, 1, 1, 2, 3, 5, 8.

Next Question →

Practice Set 7 · Question 69 of 150

Question 69. A function with one parameter is called three times sequentially and returns each time. How many completed calls are there?

  1. 1
  2. 2
  3. 3
  4. 6
Show Answer and Explanation

Correct answer: C. 3

Every invocation that returns is a completed function call; three calls complete.

Next Question →

Practice Set 7 · Question 70 of 150

Question 70. What is the main purpose of a function parameter?

  1. Specify input data for a function
  2. Force a program to stop
  3. Allocate a disk partition
  4. Replace every local variable
Show Answer and Explanation

Correct answer: A. Specify input data for a function

A parameter lets a function receive and use values or references supplied by its caller.

Continue to Practice Set 8

Practice Set 8 · Question 71 of 150

Question 71. In zero-based indexing, what is the index of the last character of a nonempty string of length 9?

  1. 8
  2. 9
  3. 10
  4. 0
Show Answer and Explanation

Correct answer: A. 8

Indexes start at 0, so the last is length−1 = 8.

Next Question →

Practice Set 8 · Question 72 of 150

Question 72. What is the result of concatenating “Hello” with “World” without adding a separator?

  1. Hello World
  2. WorldHello
  3. HelloWorld
  4. Hello+World
Show Answer and Explanation

Correct answer: C. HelloWorld

Concatenation joins the character sequences directly without an inserted space.

Next Question →

Practice Set 8 · Question 73 of 150

Question 73. What may happen if a file is opened for writing in a mode that truncates an existing file?

  1. Existing contents are discarded
  2. The file becomes read-only
  3. The file is always appended
  4. The file cannot be opened
Show Answer and Explanation

Correct answer: A. Existing contents are discarded

A truncating write mode resets the existing file’s length to zero.

Next Question →

Practice Set 8 · Question 74 of 150

Question 74. Which practice helps prevent resource leaks during file processing?

  1. Leave every file open forever
  2. Close files or use automatic resource management
  3. Repeat writes without checking errors
  4. Avoid testing end-of-file
Show Answer and Explanation

Correct answer: B. Close files or use automatic resource management

Closing files or using scoped resource management releases file handles properly.

Next Question →

Practice Set 8 · Question 75 of 150

Question 75. What is the purpose of a sentinel value in input processing?

  1. Allocate more memory
  2. Sort the input
  3. Convert a loop into recursion
  4. Signal a condition such as the end of input
Show Answer and Explanation

Correct answer: D. Signal a condition such as the end of input

A sentinel is a special value used to mark termination or another control condition.

Next Question →

Practice Set 8 · Question 76 of 150

Question 76. What is a precondition of a function?

  1. A condition expected to hold before the function is called
  2. A result guaranteed after successful execution
  3. A syntax error
  4. A type of loop
Show Answer and Explanation

Correct answer: A. A condition expected to hold before the function is called

Preconditions specify assumptions that callers should satisfy.

Next Question →

Practice Set 8 · Question 77 of 150

Question 77. Which statement about local variables is generally correct?

  1. They cannot have values
  2. Their scope is limited to the block or function where declared
  3. They are always global
  4. They automatically persist in files
Show Answer and Explanation

Correct answer: B. Their scope is limited to the block or function where declared

Local variables are accessible only within their declared scope.

Next Question →

Practice Set 8 · Question 78 of 150

Question 78. What is a nested loop?

  1. A function with two return types
  2. A compiler pass
  3. A loop contained within another loop
  4. A loop without a condition
Show Answer and Explanation

Correct answer: C. A loop contained within another loop

A nested loop executes as part of an enclosing loop body.

Next Question →

Practice Set 8 · Question 79 of 150

Question 79. Which symbol conventionally denotes assignment in the pseudocode used here?

  1. ==
  2. ↔
  3. ∪
  4. ←
Show Answer and Explanation

Correct answer: D. ←

The left arrow indicates storing the evaluated right-hand value in a variable.

Next Question →

Practice Set 8 · Question 80 of 150

Question 80. What is an off-by-one error?

  1. A mistake involving one extra or missing iteration or index
  2. A division by zero in every case
  3. A type conversion that always succeeds
  4. A network protocol
Show Answer and Explanation

Correct answer: A. A mistake involving one extra or missing iteration or index

Off-by-one errors often arise from incorrect loop boundaries.

Next Question →

Practice Set 9 · Question 81 of 150

Question 81. What is the role of a function’s return type?

  1. Count the parameters only
  2. Specify the kind of result the function produces
  3. Set the operating-system version
  4. Determine the file extension
Show Answer and Explanation

Correct answer: B. Specify the kind of result the function produces

A return type states the result’s expected data type.

Next Question →

Practice Set 9 · Question 82 of 150

Question 82. What is the result of a logical AND when one operand is false?

  1. Undefined in every language
  2. A floating-point value
  3. False
  4. True
Show Answer and Explanation

Correct answer: C. False

A conjunction is false whenever either operand is false.

Next Question →

Practice Set 9 · Question 83 of 150

Question 83. Which structure is most appropriate when choosing among several fixed alternatives?

  1. An unconditional infinite loop
  2. A single variable declaration
  3. A file pointer
  4. A multiway selection such as switch or if-else-if
Show Answer and Explanation

Correct answer: D. A multiway selection such as switch or if-else-if

Multiway selection expresses several mutually exclusive choices.

Next Question →

Practice Set 9 · Question 84 of 150

Question 84. What is a software test case?

  1. An input and expected outcome used to check a program
  2. A compiler executable
  3. A monitor setting
  4. A variable name only
Show Answer and Explanation

Correct answer: A. An input and expected outcome used to check a program

Test cases compare observed behavior with specified expectations.

Next Question →

Practice Set 9 · Question 85 of 150

Question 85. What is debugging?

  1. Changing program language automatically
  2. Finding and correcting defects in software
  3. Deleting all comments
  4. Measuring screen resolution
Show Answer and Explanation

Correct answer: B. Finding and correcting defects in software

Debugging isolates and fixes incorrect program behavior.

Next Question →

Practice Set 9 · Question 86 of 150

Question 86. Why should input be validated?

  1. To remove the need for testing
  2. To guarantee faster hardware
  3. To reject or handle malformed or out-of-range data
  4. To eliminate all program bugs
Show Answer and Explanation

Correct answer: C. To reject or handle malformed or out-of-range data

Validation checks that supplied data meets program requirements.

Next Question →

Practice Set 9 · Question 87 of 150

Question 87. What does a Boolean expression evaluate to?

  1. A file name in every case
  2. An array address only
  3. An operating-system command
  4. A truth value
Show Answer and Explanation

Correct answer: D. A truth value

Boolean expressions represent true or false conditions.

Next Question →

Practice Set 9 · Question 88 of 150

Question 88. What is a loop invariant?

  1. A property maintained before and after each iteration
  2. A value that must increase
  3. A comment used for formatting
  4. A loop that never ends
Show Answer and Explanation

Correct answer: A. A property maintained before and after each iteration

Invariants help establish the correctness of iterative algorithms.

Next Question →

Practice Set 9 · Question 89 of 150

Question 89. Why is modular programming useful?

  1. It removes all runtime costs
  2. It separates a program into manageable reusable units
  3. It prevents the use of parameters
  4. It requires global state
Show Answer and Explanation

Correct answer: B. It separates a program into manageable reusable units

Modules improve organization, reuse, testing and maintenance.

Next Question →

Practice Set 9 · Question 90 of 150

Question 90. What is a parameter in a function definition?

  1. A machine instruction
  2. The return address alone
  3. A named input variable or placeholder
  4. Always a global file
Show Answer and Explanation

Correct answer: C. A named input variable or placeholder

Parameters receive values or references supplied by function calls.

Next Question →

Practice Set 10 · Question 91 of 150

Question 91. What is an argument in a function call?

  1. A syntax error
  2. The compiler version
  3. A loop label only
  4. A value or expression passed to a parameter
Show Answer and Explanation

Correct answer: D. A value or expression passed to a parameter

Arguments supply the actual data used by the called function.

Next Question →

Practice Set 10 · Question 92 of 150

Question 92. What is a base case in recursion?

  1. A case that returns without further recursive calls
  2. The longest input
  3. A case that always recurses
  4. An unused parameter
Show Answer and Explanation

Correct answer: A. A case that returns without further recursive calls

Base cases stop recursive expansion and allow computation to unwind.

Next Question →

Practice Set 10 · Question 93 of 150

Question 93. What is a dry run of an algorithm?

  1. Disconnecting storage
  2. Tracing its steps manually with sample input
  3. Removing its output
  4. Automatically optimizing machine code
Show Answer and Explanation

Correct answer: B. Tracing its steps manually with sample input

A dry run follows intermediate values to verify program logic.

Next Question →

Practice Set 10 · Question 94 of 150

Question 94. Which data type naturally represents a yes-or-no flag?

  1. File handle
  2. Floating point exclusively
  3. Boolean
  4. Character array only
Show Answer and Explanation

Correct answer: C. Boolean

A Boolean stores one of two truth values.

Next Question →

Practice Set 10 · Question 95 of 150

Question 95. What is the difference between syntax and semantic errors?

  1. They always mean the same thing
  2. Syntax errors only happen in hardware
  3. Semantic errors are always fixed by indentation
  4. Syntax errors violate language grammar; semantic errors concern meaning or behavior
Show Answer and Explanation

Correct answer: D. Syntax errors violate language grammar; semantic errors concern meaning or behavior

Syntax checks grammatical form, while semantics concerns program meaning.

Next Question →

Practice Set 10 · Question 96 of 150

Question 96. What is an array index?

  1. A position identifier used to access an array element
  2. A processor temperature
  3. The number of source files
  4. A sorting algorithm
Show Answer and Explanation

Correct answer: A. A position identifier used to access an array element

Indexing selects an element at a particular position.

Next Question →

Practice Set 10 · Question 97 of 150

Question 97. Why is an empty input an important test case?

  1. It removes the need for assertions
  2. It can expose boundary-condition defects
  3. It guarantees successful sorting
  4. It makes loops run twice
Show Answer and Explanation

Correct answer: B. It can expose boundary-condition defects

Programs must handle an input size of zero when permitted.

Next Question →

Practice Set 10 · Question 98 of 150

Question 98. What does an assertion express in a program?

  1. A way to rename a function
  2. An instruction to ignore errors
  3. A condition expected to be true at that point
  4. A request to delete code
Show Answer and Explanation

Correct answer: C. A condition expected to be true at that point

Assertions document and check expected properties during execution.

Next Question →

Practice Set 10 · Question 99 of 150

Question 99. What is short-circuit evaluation of logical AND?

  1. Both operands must always be evaluated
  2. It changes AND into OR
  3. It converts truth values into integers
  4. The second operand need not be evaluated when the first is false
Show Answer and Explanation

Correct answer: D. The second operand need not be evaluated when the first is false

With short-circuit AND, a false first operand determines the result.

Next Question →

Practice Set 10 · Question 100 of 150

Question 100. Which loop is appropriate when the number of repetitions is known beforehand?

  1. A counted for loop
  2. Only unbounded recursion
  3. A file-write statement
  4. A constructor
Show Answer and Explanation

Correct answer: A. A counted for loop

A for loop naturally expresses a fixed or countable iteration range.

Next Question →

Practice Set 11 · Question 101 of 150

Question 101. What is a function’s side effect?

  1. Its indentation
  2. An observable change outside its returned value
  3. Its parameter count
  4. Its source-code filename
Show Answer and Explanation

Correct answer: B. An observable change outside its returned value

Writing a file or modifying external state is a side effect.

Next Question →

Practice Set 11 · Question 102 of 150

Question 102. What is the purpose of a comment in source code?

  1. Increase CPU frequency
  2. Automatically test all branches
  3. Explain intent for people reading the code
  4. Guarantee runtime correctness
Show Answer and Explanation

Correct answer: C. Explain intent for people reading the code

Comments document logic but are not normally executed.

Next Question →

Practice Set 11 · Question 103 of 150

Question 103. What is a constant in programming?

  1. A loop that repeats indefinitely
  2. A compiler message
  3. Any pointer
  4. A value or binding intended not to change during its defined use
Show Answer and Explanation

Correct answer: D. A value or binding intended not to change during its defined use

Constants represent fixed values or nonmodifiable bindings.

Next Question →

Practice Set 11 · Question 104 of 150

Question 104. What does a function call stack frame typically contain?

  1. Invocation-specific state and return information
  2. All files on disk
  3. Only network packets
  4. Every program’s source code
Show Answer and Explanation

Correct answer: A. Invocation-specific state and return information

Stack frames maintain state for active calls.

Next Question →

Practice Set 11 · Question 105 of 150

Question 105. What is the usual purpose of a break statement in a loop?

  1. Convert all values to strings
  2. Exit the nearest enclosing loop or switch where applicable
  3. Restart the operating system
  4. Declare an array
Show Answer and Explanation

Correct answer: B. Exit the nearest enclosing loop or switch where applicable

Break transfers control beyond the applicable loop or switch.

Next Question →

Practice Set 11 · Question 106 of 150

Question 106. What does continue usually do within a loop?

  1. Compile the current function
  2. Delete loop variables
  3. Skip to the next iteration
  4. Exit the whole program
Show Answer and Explanation

Correct answer: C. Skip to the next iteration

Continue bypasses the remaining current loop body and advances iteration.

Next Question →

Practice Set 11 · Question 107 of 150

Question 107. When does a while loop execute zero times?

  1. Whenever a variable is numeric
  2. Only if it has no body
  3. Never
  4. When its condition is initially false
Show Answer and Explanation

Correct answer: D. When its condition is initially false

The condition is tested before entering a while loop.

Next Question →

Practice Set 11 · Question 108 of 150

Question 108. What is the purpose of a function prototype in C or C++?

  1. Declare a function interface before its use
  2. Guarantee an algorithm terminates
  3. Create a new file automatically
  4. Prevent parameter passing
Show Answer and Explanation

Correct answer: A. Declare a function interface before its use

A prototype informs the compiler about parameter and return types.

Next Question →

Practice Set 11 · Question 109 of 150

Question 109. Why should a file-open operation be checked?

  1. It sets the number of loops
  2. It can fail due to missing files or permissions
  3. It always succeeds
  4. It is needed only for arithmetic
Show Answer and Explanation

Correct answer: B. It can fail due to missing files or permissions

Robust programs handle possible I/O failures.

Next Question →

Practice Set 11 · Question 110 of 150

Question 110. What is a memory leak?

  1. A correct bounds check
  2. A type of integer literal
  3. Allocated memory that is no longer released or appropriately reclaimed
  4. A repeated function name
Show Answer and Explanation

Correct answer: C. Allocated memory that is no longer released or appropriately reclaimed

Unreleased resources can accumulate during execution.

Next Question →

Practice Set 12 · Question 111 of 150

Question 111. Evaluate the pseudocode: x←3; y←2; x←2*x+y. What is x?

  1. 9
  2. 7
  3. 10
  4. 8
Show Answer and Explanation

Correct answer: D. 8

Substitute x=3 and y=2: 2×3+2=8.

Next Question →

Practice Set 12 · Question 112 of 150

Question 112. Evaluate the pseudocode: x←4; y←3; x←2*x+y. What is x?

  1. 11
  2. 12
  3. 10
  4. 13
Show Answer and Explanation

Correct answer: A. 11

Substitute x=4 and y=3: 2×4+3=11.

Next Question →

Practice Set 12 · Question 113 of 150

Question 113. Evaluate the pseudocode: x←5; y←4; x←2*x+y. What is x?

  1. 16
  2. 14
  3. 15
  4. 13
Show Answer and Explanation

Correct answer: B. 14

Substitute x=5 and y=4: 2×5+4=14.

Next Question →

Practice Set 12 · Question 114 of 150

Question 114. Evaluate the pseudocode: x←6; y←5; x←2*x+y. What is x?

  1. 16
  2. 19
  3. 17
  4. 18
Show Answer and Explanation

Correct answer: C. 17

Substitute x=6 and y=5: 2×6+5=17.

Next Question →

Practice Set 12 · Question 115 of 150

Question 115. Evaluate the pseudocode: x←7; y←6; x←2*x+y. What is x?

  1. 21
  2. 19
  3. 22
  4. 20
Show Answer and Explanation

Correct answer: D. 20

Substitute x=7 and y=6: 2×7+6=20.

Next Question →

Practice Set 12 · Question 116 of 150

Question 116. Evaluate the pseudocode: x←8; y←7; x←2*x+y. What is x?

  1. 23
  2. 24
  3. 22
  4. 25
Show Answer and Explanation

Correct answer: A. 23

Substitute x=8 and y=7: 2×8+7=23.

Next Question →

Practice Set 12 · Question 117 of 150

Question 117. Evaluate the pseudocode: x←9; y←8; x←2*x+y. What is x?

  1. 28
  2. 26
  3. 27
  4. 25
Show Answer and Explanation

Correct answer: B. 26

Substitute x=9 and y=8: 2×9+8=26.

Next Question →

Practice Set 12 · Question 118 of 150

Question 118. Evaluate the pseudocode: x←10; y←9; x←2*x+y. What is x?

  1. 28
  2. 31
  3. 29
  4. 30
Show Answer and Explanation

Correct answer: C. 29

Substitute x=10 and y=9: 2×10+9=29.

Next Question →

Practice Set 12 · Question 119 of 150

Question 119. Evaluate the pseudocode: x←11; y←10; x←2*x+y. What is x?

  1. 33
  2. 31
  3. 34
  4. 32
Show Answer and Explanation

Correct answer: D. 32

Substitute x=11 and y=10: 2×11+10=32.

Next Question →

Practice Set 12 · Question 120 of 150

Question 120. Evaluate the pseudocode: x←12; y←11; x←2*x+y. What is x?

  1. 35
  2. 36
  3. 34
  4. 37
Show Answer and Explanation

Correct answer: A. 35

Substitute x=12 and y=11: 2×12+11=35.

Next Question →

Practice Set 13 · Question 121 of 150

Question 121. In an inclusive loop FOR i←1 TO 4, add i to total initially zero. Find total.

  1. 4
  2. 10
  3. 11
  4. 9
Show Answer and Explanation

Correct answer: B. 10

The total is the arithmetic sum 4(4+1)/2=10.

Next Question →

Practice Set 13 · Question 122 of 150

Question 122. In an inclusive loop FOR i←1 TO 5, add i to total initially zero. Find total.

  1. 14
  2. 5
  3. 15
  4. 16
Show Answer and Explanation

Correct answer: C. 15

The total is the arithmetic sum 5(5+1)/2=15.

Next Question →

Practice Set 13 · Question 123 of 150

Question 123. In an inclusive loop FOR i←1 TO 6, add i to total initially zero. Find total.

  1. 22
  2. 20
  3. 6
  4. 21
Show Answer and Explanation

Correct answer: D. 21

The total is the arithmetic sum 6(6+1)/2=21.

Next Question →

Practice Set 13 · Question 124 of 150

Question 124. In an inclusive loop FOR i←1 TO 7, add i to total initially zero. Find total.

  1. 28
  2. 29
  3. 27
  4. 7
Show Answer and Explanation

Correct answer: A. 28

The total is the arithmetic sum 7(7+1)/2=28.

Next Question →

Practice Set 13 · Question 125 of 150

Question 125. In an inclusive loop FOR i←1 TO 8, add i to total initially zero. Find total.

  1. 8
  2. 36
  3. 37
  4. 35
Show Answer and Explanation

Correct answer: B. 36

The total is the arithmetic sum 8(8+1)/2=36.

Next Question →

Practice Set 13 · Question 126 of 150

Question 126. In an inclusive loop FOR i←1 TO 9, add i to total initially zero. Find total.

  1. 44
  2. 9
  3. 45
  4. 46
Show Answer and Explanation

Correct answer: C. 45

The total is the arithmetic sum 9(9+1)/2=45.

Next Question →

Practice Set 13 · Question 127 of 150

Question 127. In an inclusive loop FOR i←1 TO 10, add i to total initially zero. Find total.

  1. 56
  2. 54
  3. 10
  4. 55
Show Answer and Explanation

Correct answer: D. 55

The total is the arithmetic sum 10(10+1)/2=55.

Next Question →

Practice Set 13 · Question 128 of 150

Question 128. In an inclusive loop FOR i←1 TO 11, add i to total initially zero. Find total.

  1. 66
  2. 67
  3. 65
  4. 11
Show Answer and Explanation

Correct answer: A. 66

The total is the arithmetic sum 11(11+1)/2=66.

Next Question →

Practice Set 13 · Question 129 of 150

Question 129. In an inclusive loop FOR i←1 TO 12, add i to total initially zero. Find total.

  1. 12
  2. 78
  3. 79
  4. 77
Show Answer and Explanation

Correct answer: B. 78

The total is the arithmetic sum 12(12+1)/2=78.

Next Question →

Practice Set 13 · Question 130 of 150

Question 130. In an inclusive loop FOR i←1 TO 13, add i to total initially zero. Find total.

  1. 90
  2. 13
  3. 91
  4. 92
Show Answer and Explanation

Correct answer: C. 91

The total is the arithmetic sum 13(13+1)/2=91.

Next Question →

Practice Set 14 · Question 131 of 150

Question 131. For nonnegative integer n=6, compute n MOD 4.

  1. 3
  2. 0
  3. 1
  4. 2
Show Answer and Explanation

Correct answer: D. 2

Modulo gives the remainder when 6 is divided by 4, which is 2.

Next Question →

Practice Set 14 · Question 132 of 150

Question 132. For nonnegative integer n=7, compute n MOD 4.

  1. 3
  2. 0
  3. 1
  4. 2
Show Answer and Explanation

Correct answer: A. 3

Modulo gives the remainder when 7 is divided by 4, which is 3.

Next Question →

Practice Set 14 · Question 133 of 150

Question 133. For nonnegative integer n=8, compute n MOD 4.

  1. 3
  2. 0
  3. 1
  4. 2
Show Answer and Explanation

Correct answer: B. 0

Modulo gives the remainder when 8 is divided by 4, which is 0.

Next Question →

Practice Set 14 · Question 134 of 150

Question 134. For nonnegative integer n=9, compute n MOD 4.

  1. 3
  2. 0
  3. 1
  4. 2
Show Answer and Explanation

Correct answer: C. 1

Modulo gives the remainder when 9 is divided by 4, which is 1.

Next Question →

Practice Set 14 · Question 135 of 150

Question 135. For nonnegative integer n=10, compute n MOD 4.

  1. 3
  2. 0
  3. 1
  4. 2
Show Answer and Explanation

Correct answer: D. 2

Modulo gives the remainder when 10 is divided by 4, which is 2.

Next Question →

Practice Set 14 · Question 136 of 150

Question 136. For nonnegative integer n=11, compute n MOD 4.

  1. 3
  2. 0
  3. 1
  4. 2
Show Answer and Explanation

Correct answer: A. 3

Modulo gives the remainder when 11 is divided by 4, which is 3.

Next Question →

Practice Set 14 · Question 137 of 150

Question 137. For nonnegative integer n=12, compute n MOD 4.

  1. 3
  2. 0
  3. 1
  4. 2
Show Answer and Explanation

Correct answer: B. 0

Modulo gives the remainder when 12 is divided by 4, which is 0.

Next Question →

Practice Set 14 · Question 138 of 150

Question 138. For nonnegative integer n=13, compute n MOD 4.

  1. 3
  2. 0
  3. 1
  4. 2
Show Answer and Explanation

Correct answer: C. 1

Modulo gives the remainder when 13 is divided by 4, which is 1.

Next Question →

Practice Set 14 · Question 139 of 150

Question 139. For nonnegative integer n=14, compute n MOD 4.

  1. 3
  2. 0
  3. 1
  4. 2
Show Answer and Explanation

Correct answer: D. 2

Modulo gives the remainder when 14 is divided by 4, which is 2.

Next Question →

Practice Set 14 · Question 140 of 150

Question 140. For nonnegative integer n=15, compute n MOD 4.

  1. 3
  2. 0
  3. 1
  4. 2
Show Answer and Explanation

Correct answer: A. 3

Modulo gives the remainder when 15 is divided by 4, which is 3.

Next Question →

Practice Set 15 · Question 141 of 150

Question 141. Suppose square(x) returns x*x. Evaluate square(3).

  1. 6
  2. 9
  3. 10
  4. 8
Show Answer and Explanation

Correct answer: B. 9

The function multiplies 3 by itself, giving 9.

Next Question →

Practice Set 15 · Question 142 of 150

Question 142. Suppose square(x) returns x*x. Evaluate square(4).

  1. 15
  2. 8
  3. 16
  4. 17
Show Answer and Explanation

Correct answer: C. 16

The function multiplies 4 by itself, giving 16.

Next Question →

Practice Set 15 · Question 143 of 150

Question 143. Suppose square(x) returns x*x. Evaluate square(5).

  1. 26
  2. 24
  3. 10
  4. 25
Show Answer and Explanation

Correct answer: D. 25

The function multiplies 5 by itself, giving 25.

Next Question →

Practice Set 15 · Question 144 of 150

Question 144. Suppose square(x) returns x*x. Evaluate square(6).

  1. 36
  2. 37
  3. 35
  4. 12
Show Answer and Explanation

Correct answer: A. 36

The function multiplies 6 by itself, giving 36.

Next Question →

Practice Set 15 · Question 145 of 150

Question 145. Suppose square(x) returns x*x. Evaluate square(7).

  1. 14
  2. 49
  3. 50
  4. 48
Show Answer and Explanation

Correct answer: B. 49

The function multiplies 7 by itself, giving 49.

Next Question →

Practice Set 15 · Question 146 of 150

Question 146. Suppose square(x) returns x*x. Evaluate square(8).

  1. 63
  2. 16
  3. 64
  4. 65
Show Answer and Explanation

Correct answer: C. 64

The function multiplies 8 by itself, giving 64.

Next Question →

Practice Set 15 · Question 147 of 150

Question 147. Suppose square(x) returns x*x. Evaluate square(9).

  1. 82
  2. 80
  3. 18
  4. 81
Show Answer and Explanation

Correct answer: D. 81

The function multiplies 9 by itself, giving 81.

Next Question →

Practice Set 15 · Question 148 of 150

Question 148. Suppose square(x) returns x*x. Evaluate square(10).

  1. 100
  2. 101
  3. 99
  4. 20
Show Answer and Explanation

Correct answer: A. 100

The function multiplies 10 by itself, giving 100.

Next Question →

Practice Set 15 · Question 149 of 150

Question 149. Suppose square(x) returns x*x. Evaluate square(11).

  1. 22
  2. 121
  3. 122
  4. 120
Show Answer and Explanation

Correct answer: B. 121

The function multiplies 11 by itself, giving 121.

Next Question →

Practice Set 15 · Question 150 of 150

Question 150. Suppose square(x) returns x*x. Evaluate square(12).

  1. 143
  2. 24
  3. 144
  4. 145
Show Answer and Explanation

Correct answer: C. 144

The function multiplies 12 by itself, giving 144.

Restart from Question 1

Return to the full course materials and worked examples