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.
Question 1. What is an algorithm?
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.
Question 2. Which property means that an algorithm eventually stops?
Show Answer and Explanation
Correct answer: B. Finiteness
Finiteness requires an algorithm to terminate after a limited number of steps.
Question 3. Which sequence best describes a common problem-solving process?
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.
Question 4. What is the primary function of a compiler?
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.
Question 5. What does a linker commonly do?
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.
Question 6. In the classic von Neumann model, where are instructions and data stored?
Show Answer and Explanation
Correct answer: B. In the same main memory
The stored-program model places instructions and data in addressable memory.
Question 7. Which of these is a Boolean value?
Show Answer and Explanation
Correct answer: C. TRUE
A Boolean value is either true or false.
Question 8. If x ← 7 and y ← 3, what is x + 2 × y?
Show Answer and Explanation
Correct answer: B. 13
Multiplication comes first: 2 × 3 = 6, so 7 + 6 = 13.
Question 9. With integer division defined as discarding the remainder for nonnegative integers, what is 17 DIV 5?
Show Answer and Explanation
Correct answer: B. 3
17 = 5 × 3 + 2, so the integer quotient is 3.
Question 10. What is 17 MOD 5?
Show Answer and Explanation
Correct answer: A. 2
MOD returns the remainder; dividing 17 by 5 leaves remainder 2.
Question 11. If a ← 4, then a ← a + 6, what is the final value of a?
Show Answer and Explanation
Correct answer: C. 10
The right-hand expression uses the old value: 4 + 6 = 10, then assigns 10 to a.
Question 12. Which expression is TRUE when x = 8?
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.
Question 13. What is the purpose of an IF statement?
Show Answer and Explanation
Correct answer: B. Select actions based on a condition
An IF statement executes a branch according to a Boolean condition.
Question 14. If score = 49, what does IF score ≥ 50 THEN print(“Pass”) ELSE print(“Retry”) output?
Show Answer and Explanation
Correct answer: B. Retry
49 does not meet the threshold of 50, so the ELSE branch prints Retry.
Question 15. What does a WHILE loop check before each iteration?
Show Answer and Explanation
Correct answer: B. Its loop condition
A WHILE loop evaluates its condition before executing each iteration.
Question 16. In pseudocode, x ← 1; WHILE x < 5: x ← x + 2. What is x after the loop?
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.
Question 17. How many times is the body executed for FOR i ← 1 TO 4 (inclusive)?
Show Answer and Explanation
Correct answer: B. 4
The index takes the values 1, 2, 3 and 4, yielding four iterations.
Question 18. What condition most directly risks an infinite WHILE loop?
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.
Question 19. For zero-based array A = [5, 9, 2, 8], what is A[2]?
Show Answer and Explanation
Correct answer: C. 2
Zero-based positions are 0, 1, 2 and 3; A[2] is the third value, 2.
Question 20. Which is the main benefit of placing repeated logic in a function?
Show Answer and Explanation
Correct answer: B. It improves reuse and organisation
Functions package reusable behaviour and help structure programs into manageable parts.
Question 21. Suppose square(n) returns n × n. What is square(6)?
Show Answer and Explanation
Correct answer: C. 36
Substituting n = 6 gives 6 × 6 = 36.
Question 22. In a two-dimensional array, which pair identifies an element?
Show Answer and Explanation
Correct answer: B. Row and column indices
A two-dimensional array is indexed using two positions, commonly row and column.
Question 23. If a function returns a value, what does RETURN normally do?
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.
Question 24. What is a string in introductory programming?
Show Answer and Explanation
Correct answer: A. A sequence of characters
A string represents text as a sequence of characters.
Question 25. Which operation typically obtains data from a stored file?
Show Answer and Explanation
Correct answer: A. File read
Reading a file retrieves its stored bytes or text for processing.
Question 26. What is dynamic memory allocation?
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.
Question 27. What does a pointer generally store in a language such as C?
Show Answer and Explanation
Correct answer: A. A memory address
A pointer holds an address that can identify a memory location.
Question 28. Which operation joins the strings “data” and “base” into “database”?
Show Answer and Explanation
Correct answer: B. Concatenation
String concatenation combines two sequences of characters end to end.
Question 29. Why is closing a file after use generally important?
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.
Question 30. A program reads one line from a text file. Which case must robust code handle?
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.
Question 31. What does binary search require?
Show Answer and Explanation
Correct answer: A. Sorted search data
The ordering permits half of the current search interval to be discarded.
Question 32. Starting n = 1, repeatedly double n while n < 20. What is final n?
Show Answer and Explanation
Correct answer: C. 32
1, 2, 4, 8, 16, 32; at 32 the condition is false.
Question 33. Which flowchart symbol commonly means a decision?
Show Answer and Explanation
Correct answer: B. Diamond
A diamond denotes branching on a condition.
Question 34. Which test case probes an empty-array boundary?
Show Answer and Explanation
Correct answer: B. Length 0
A zero-length input checks handling of no elements.
Question 35. For x=5 and y=9, evaluate NOT(x > 7 OR y < 4).
Show Answer and Explanation
Correct answer: A. TRUE
Both comparisons are false; NOT(false OR false) is true.
Question 36. For nonnegative integer arithmetic, evaluate (10 MOD 4) × (10 DIV 4).
Show Answer and Explanation
Correct answer: B. 4
The remainder and integer quotient are both 2; product is 4.
Question 37. Evaluate 3 + 12 / 4 × 2 using usual precedence and left associativity.
Show Answer and Explanation
Correct answer: B. 9
12 / 4 = 3; 3 × 2 = 6; 3 + 6 = 9.
Question 38. NOT(A AND B) is equivalent to which expression?
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.
Question 39. For i from 2 to 6 inclusive with step 2, sum all i. What is the sum?
Show Answer and Explanation
Correct answer: C. 12
The visited values are 2, 4, 6; their sum is 12.
Question 40. If a WHILE condition is initially false, how many times is its body executed?
Show Answer and Explanation
Correct answer: A. 0
WHILE checks its condition before entering the body.
Question 41. What are the valid zero-based indexes of an array of length n > 0?
Show Answer and Explanation
Correct answer: C. 0 through n−1
The first index is 0 and the last valid index is n−1.
Question 42. x ← 12; WHILE x > 3: x ← x DIV 2. What is final x?
Show Answer and Explanation
Correct answer: C. 3
12 changes to 6 and then 3; the loop then stops.
Question 43. For B=[4,7,1,9,2] with zero-based indexing, what is B[1]+B[4]?
Show Answer and Explanation
Correct answer: C. 9
7 + 2 = 9.
Question 44. How many elements are in a rectangular 3-by-4 array?
Show Answer and Explanation
Correct answer: C. 12
Multiply rows by columns: 3 × 4 = 12.
Question 45. What is the character at index 3 in the string LEVEL (zero-based)?
Show Answer and Explanation
Correct answer: B. E
Positions 0–4 are L, E, V, E, L.
Question 46. What is typical indexed-access time for a contiguous array A[k]?
Show Answer and Explanation
Correct answer: A. O(1)
The index determines the element address in constant time under the standard array model.
Question 47. What is needed for terminating recursive computation on valid inputs?
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.
Question 48. Given factorial(0)=1 and factorial(n)=n×factorial(n−1), what is factorial(4)?
Show Answer and Explanation
Correct answer: C. 24
4×3×2×1 = 24.
Question 49. A function modifies a pass-by-value integer parameter. What happens to the caller’s variable?
Show Answer and Explanation
Correct answer: B. Remains unchanged
Pass-by-value operates on a separate local value.
Question 50. The call stack commonly tracks which information?
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.
Question 51. Unreleased dynamic allocations in a manually managed environment may cause what?
Show Answer and Explanation
Correct answer: A. Memory leak
Memory that is never freed can accumulate.
Question 52. How should a program handle reading past end-of-file?
Show Answer and Explanation
Correct answer: A. Check for EOF or read failure
Read results must be checked before processing.
Question 53. Which file mode normally adds new data to the end of existing content?
Show Answer and Explanation
Correct answer: B. Append
Append writes at the end rather than replacing earlier data.
Question 54. What is a dangling pointer?
Show Answer and Explanation
Correct answer: A. A pointer to an object whose lifetime ended
References to objects that no longer exist are invalid.
Question 55. A loop visits every element of an array of size n exactly once. What is its time complexity?
Show Answer and Explanation
Correct answer: C. O(n)
There are n visits with constant work each, so total time is O(n).
Question 56. Two nested loops each execute n times, with constant work inside. What is their complexity?
Show Answer and Explanation
Correct answer: A. O(n²)
There are n × n iterations, so the running time is O(n²).
Question 57. Binary search on a sorted array of 64 items requires at most how many comparisons to find an item or establish absence?
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.
Question 58. An algorithm uses two integer variables and no input-sized auxiliary data. What is its auxiliary space complexity?
Show Answer and Explanation
Correct answer: A. O(1)
A constant number of scalar variables needs constant auxiliary space.
Question 59. Given x ← 2; y ← 5; x ← x + y; y ← x − y; x ← x − y, what are (x, y)?
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).
Question 60. What is x after x ← 0; FOR i ← 1 TO 4 inclusive: x ← x + i × i?
Show Answer and Explanation
Correct answer: C. 30
The sum of squares is 1 + 4 + 9 + 16 = 30.
Question 61. Let a ← 7. IF a MOD 2 = 0 THEN a ← a DIV 2 ELSE a ← 3 × a + 1. What is a?
Show Answer and Explanation
Correct answer: D. 22
Since 7 is odd, the ELSE branch assigns 3×7+1 = 22.
Question 62. For n ← 18; count ← 0; WHILE n > 1: n ← n DIV 2; count ← count + 1, what is count?
Show Answer and Explanation
Correct answer: B. 4
The values of n after iterations are 9, 4, 2, 1; four iterations occur.
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?
Show Answer and Explanation
Correct answer: C. 12
The indexed values are 3, 4 and 5; their sum is 12.
Question 64. What is the result of reversing the array [2, 7, 9, 4]?
Show Answer and Explanation
Correct answer: A. [4, 9, 7, 2]
Reversing swaps the first and last positions and the two middle positions.
Question 65. For a 4-row, 3-column array, how many elements are there?
Show Answer and Explanation
Correct answer: B. 12
The array contains 4 × 3 = 12 elements.
Question 66. Which search method can work on an unsorted array without preprocessing?
Show Answer and Explanation
Correct answer: B. Linear search
Linear search compares each candidate in turn and does not require sorting.
Question 67. If f(x) returns 2x + 3, what is f(f(1))?
Show Answer and Explanation
Correct answer: C. 13
First f(1)=5, then f(5)=2×5+3=13.
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)?
Show Answer and Explanation
Correct answer: B. 8
The terms from f(0) to f(6) are 0, 1, 1, 2, 3, 5, 8.
Question 69. A function with one parameter is called three times sequentially and returns each time. How many completed calls are there?
Show Answer and Explanation
Correct answer: C. 3
Every invocation that returns is a completed function call; three calls complete.
Question 70. What is the main purpose of a function parameter?
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.
Question 71. In zero-based indexing, what is the index of the last character of a nonempty string of length 9?
Show Answer and Explanation
Correct answer: A. 8
Indexes start at 0, so the last is length−1 = 8.
Question 72. What is the result of concatenating “Hello” with “World” without adding a separator?
Show Answer and Explanation
Correct answer: C. HelloWorld
Concatenation joins the character sequences directly without an inserted space.
Question 73. What may happen if a file is opened for writing in a mode that truncates an existing file?
Show Answer and Explanation
Correct answer: A. Existing contents are discarded
A truncating write mode resets the existing file’s length to zero.
Question 74. Which practice helps prevent resource leaks during file processing?
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.
Question 75. What is the purpose of a sentinel value in input processing?
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.
Question 76. What is a precondition of a function?
Show Answer and Explanation
Correct answer: A. A condition expected to hold before the function is called
Preconditions specify assumptions that callers should satisfy.
Question 77. Which statement about local variables is generally correct?
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.
Question 78. What is a nested loop?
Show Answer and Explanation
Correct answer: C. A loop contained within another loop
A nested loop executes as part of an enclosing loop body.
Question 79. Which symbol conventionally denotes assignment in the pseudocode used here?
Show Answer and Explanation
Correct answer: D. ←
The left arrow indicates storing the evaluated right-hand value in a variable.
Question 80. What is an off-by-one error?
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.
Question 81. What is the role of a function’s return type?
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.
Question 82. What is the result of a logical AND when one operand is false?
Show Answer and Explanation
Correct answer: C. False
A conjunction is false whenever either operand is false.
Question 83. Which structure is most appropriate when choosing among several fixed alternatives?
Show Answer and Explanation
Correct answer: D. A multiway selection such as switch or if-else-if
Multiway selection expresses several mutually exclusive choices.
Question 84. What is a software test case?
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.
Question 85. What is debugging?
Show Answer and Explanation
Correct answer: B. Finding and correcting defects in software
Debugging isolates and fixes incorrect program behavior.
Question 86. Why should input be validated?
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.
Question 87. What does a Boolean expression evaluate to?
Show Answer and Explanation
Correct answer: D. A truth value
Boolean expressions represent true or false conditions.
Question 88. What is a loop invariant?
Show Answer and Explanation
Correct answer: A. A property maintained before and after each iteration
Invariants help establish the correctness of iterative algorithms.
Question 89. Why is modular programming useful?
Show Answer and Explanation
Correct answer: B. It separates a program into manageable reusable units
Modules improve organization, reuse, testing and maintenance.
Question 90. What is a parameter in a function definition?
Show Answer and Explanation
Correct answer: C. A named input variable or placeholder
Parameters receive values or references supplied by function calls.
Question 91. What is an argument in a function call?
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.
Question 92. What is a base case in recursion?
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.
Question 93. What is a dry run of an algorithm?
Show Answer and Explanation
Correct answer: B. Tracing its steps manually with sample input
A dry run follows intermediate values to verify program logic.
Question 94. Which data type naturally represents a yes-or-no flag?
Show Answer and Explanation
Correct answer: C. Boolean
A Boolean stores one of two truth values.
Question 95. What is the difference between syntax and semantic errors?
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.
Question 96. What is an array index?
Show Answer and Explanation
Correct answer: A. A position identifier used to access an array element
Indexing selects an element at a particular position.
Question 97. Why is an empty input an important test case?
Show Answer and Explanation
Correct answer: B. It can expose boundary-condition defects
Programs must handle an input size of zero when permitted.
Question 98. What does an assertion express in a program?
Show Answer and Explanation
Correct answer: C. A condition expected to be true at that point
Assertions document and check expected properties during execution.
Question 99. What is short-circuit evaluation of logical AND?
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.
Question 100. Which loop is appropriate when the number of repetitions is known beforehand?
Show Answer and Explanation
Correct answer: A. A counted for loop
A for loop naturally expresses a fixed or countable iteration range.
Question 101. What is a function’s side effect?
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.
Question 102. What is the purpose of a comment in source code?
Show Answer and Explanation
Correct answer: C. Explain intent for people reading the code
Comments document logic but are not normally executed.
Question 103. What is a constant in programming?
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.
Question 104. What does a function call stack frame typically contain?
Show Answer and Explanation
Correct answer: A. Invocation-specific state and return information
Stack frames maintain state for active calls.
Question 105. What is the usual purpose of a break statement in a loop?
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.
Question 106. What does continue usually do within a loop?
Show Answer and Explanation
Correct answer: C. Skip to the next iteration
Continue bypasses the remaining current loop body and advances iteration.
Question 107. When does a while loop execute zero times?
Show Answer and Explanation
Correct answer: D. When its condition is initially false
The condition is tested before entering a while loop.
Question 108. What is the purpose of a function prototype in C or C++?
Show Answer and Explanation
Correct answer: A. Declare a function interface before its use
A prototype informs the compiler about parameter and return types.
Question 109. Why should a file-open operation be checked?
Show Answer and Explanation
Correct answer: B. It can fail due to missing files or permissions
Robust programs handle possible I/O failures.
Question 110. What is a memory leak?
Show Answer and Explanation
Correct answer: C. Allocated memory that is no longer released or appropriately reclaimed
Unreleased resources can accumulate during execution.
Question 111. Evaluate the pseudocode: x←3; y←2; x←2*x+y. What is x?
Show Answer and Explanation
Correct answer: D. 8
Substitute x=3 and y=2: 2×3+2=8.
Question 112. Evaluate the pseudocode: x←4; y←3; x←2*x+y. What is x?
Show Answer and Explanation
Correct answer: A. 11
Substitute x=4 and y=3: 2×4+3=11.
Question 113. Evaluate the pseudocode: x←5; y←4; x←2*x+y. What is x?
Show Answer and Explanation
Correct answer: B. 14
Substitute x=5 and y=4: 2×5+4=14.
Question 114. Evaluate the pseudocode: x←6; y←5; x←2*x+y. What is x?
Show Answer and Explanation
Correct answer: C. 17
Substitute x=6 and y=5: 2×6+5=17.
Question 115. Evaluate the pseudocode: x←7; y←6; x←2*x+y. What is x?
Show Answer and Explanation
Correct answer: D. 20
Substitute x=7 and y=6: 2×7+6=20.
Question 116. Evaluate the pseudocode: x←8; y←7; x←2*x+y. What is x?
Show Answer and Explanation
Correct answer: A. 23
Substitute x=8 and y=7: 2×8+7=23.
Question 117. Evaluate the pseudocode: x←9; y←8; x←2*x+y. What is x?
Show Answer and Explanation
Correct answer: B. 26
Substitute x=9 and y=8: 2×9+8=26.
Question 118. Evaluate the pseudocode: x←10; y←9; x←2*x+y. What is x?
Show Answer and Explanation
Correct answer: C. 29
Substitute x=10 and y=9: 2×10+9=29.
Question 119. Evaluate the pseudocode: x←11; y←10; x←2*x+y. What is x?
Show Answer and Explanation
Correct answer: D. 32
Substitute x=11 and y=10: 2×11+10=32.
Question 120. Evaluate the pseudocode: x←12; y←11; x←2*x+y. What is x?
Show Answer and Explanation
Correct answer: A. 35
Substitute x=12 and y=11: 2×12+11=35.
Question 121. In an inclusive loop FOR i←1 TO 4, add i to total initially zero. Find total.
Show Answer and Explanation
Correct answer: B. 10
The total is the arithmetic sum 4(4+1)/2=10.
Question 122. In an inclusive loop FOR i←1 TO 5, add i to total initially zero. Find total.
Show Answer and Explanation
Correct answer: C. 15
The total is the arithmetic sum 5(5+1)/2=15.
Question 123. In an inclusive loop FOR i←1 TO 6, add i to total initially zero. Find total.
Show Answer and Explanation
Correct answer: D. 21
The total is the arithmetic sum 6(6+1)/2=21.
Question 124. In an inclusive loop FOR i←1 TO 7, add i to total initially zero. Find total.
Show Answer and Explanation
Correct answer: A. 28
The total is the arithmetic sum 7(7+1)/2=28.
Question 125. In an inclusive loop FOR i←1 TO 8, add i to total initially zero. Find total.
Show Answer and Explanation
Correct answer: B. 36
The total is the arithmetic sum 8(8+1)/2=36.
Question 126. In an inclusive loop FOR i←1 TO 9, add i to total initially zero. Find total.
Show Answer and Explanation
Correct answer: C. 45
The total is the arithmetic sum 9(9+1)/2=45.
Question 127. In an inclusive loop FOR i←1 TO 10, add i to total initially zero. Find total.
Show Answer and Explanation
Correct answer: D. 55
The total is the arithmetic sum 10(10+1)/2=55.
Question 128. In an inclusive loop FOR i←1 TO 11, add i to total initially zero. Find total.
Show Answer and Explanation
Correct answer: A. 66
The total is the arithmetic sum 11(11+1)/2=66.
Question 129. In an inclusive loop FOR i←1 TO 12, add i to total initially zero. Find total.
Show Answer and Explanation
Correct answer: B. 78
The total is the arithmetic sum 12(12+1)/2=78.
Question 130. In an inclusive loop FOR i←1 TO 13, add i to total initially zero. Find total.
Show Answer and Explanation
Correct answer: C. 91
The total is the arithmetic sum 13(13+1)/2=91.
Question 131. For nonnegative integer n=6, compute n MOD 4.
Show Answer and Explanation
Correct answer: D. 2
Modulo gives the remainder when 6 is divided by 4, which is 2.
Question 132. For nonnegative integer n=7, compute n MOD 4.
Show Answer and Explanation
Correct answer: A. 3
Modulo gives the remainder when 7 is divided by 4, which is 3.
Question 133. For nonnegative integer n=8, compute n MOD 4.
Show Answer and Explanation
Correct answer: B. 0
Modulo gives the remainder when 8 is divided by 4, which is 0.
Question 134. For nonnegative integer n=9, compute n MOD 4.
Show Answer and Explanation
Correct answer: C. 1
Modulo gives the remainder when 9 is divided by 4, which is 1.
Question 135. For nonnegative integer n=10, compute n MOD 4.
Show Answer and Explanation
Correct answer: D. 2
Modulo gives the remainder when 10 is divided by 4, which is 2.
Question 136. For nonnegative integer n=11, compute n MOD 4.
Show Answer and Explanation
Correct answer: A. 3
Modulo gives the remainder when 11 is divided by 4, which is 3.
Question 137. For nonnegative integer n=12, compute n MOD 4.
Show Answer and Explanation
Correct answer: B. 0
Modulo gives the remainder when 12 is divided by 4, which is 0.
Question 138. For nonnegative integer n=13, compute n MOD 4.
Show Answer and Explanation
Correct answer: C. 1
Modulo gives the remainder when 13 is divided by 4, which is 1.
Question 139. For nonnegative integer n=14, compute n MOD 4.
Show Answer and Explanation
Correct answer: D. 2
Modulo gives the remainder when 14 is divided by 4, which is 2.
Question 140. For nonnegative integer n=15, compute n MOD 4.
Show Answer and Explanation
Correct answer: A. 3
Modulo gives the remainder when 15 is divided by 4, which is 3.
Question 141. Suppose square(x) returns x*x. Evaluate square(3).
Show Answer and Explanation
Correct answer: B. 9
The function multiplies 3 by itself, giving 9.
Question 142. Suppose square(x) returns x*x. Evaluate square(4).
Show Answer and Explanation
Correct answer: C. 16
The function multiplies 4 by itself, giving 16.
Question 143. Suppose square(x) returns x*x. Evaluate square(5).
Show Answer and Explanation
Correct answer: D. 25
The function multiplies 5 by itself, giving 25.
Question 144. Suppose square(x) returns x*x. Evaluate square(6).
Show Answer and Explanation
Correct answer: A. 36
The function multiplies 6 by itself, giving 36.
Question 145. Suppose square(x) returns x*x. Evaluate square(7).
Show Answer and Explanation
Correct answer: B. 49
The function multiplies 7 by itself, giving 49.
Question 146. Suppose square(x) returns x*x. Evaluate square(8).
Show Answer and Explanation
Correct answer: C. 64
The function multiplies 8 by itself, giving 64.
Question 147. Suppose square(x) returns x*x. Evaluate square(9).
Show Answer and Explanation
Correct answer: D. 81
The function multiplies 9 by itself, giving 81.
Question 148. Suppose square(x) returns x*x. Evaluate square(10).
Show Answer and Explanation
Correct answer: A. 100
The function multiplies 10 by itself, giving 100.
Question 149. Suppose square(x) returns x*x. Evaluate square(11).
Show Answer and Explanation
Correct answer: B. 121
The function multiplies 11 by itself, giving 121.
Question 150. Suppose square(x) returns x*x. Evaluate square(12).
Show Answer and Explanation
Correct answer: C. 144
The function multiplies 12 by itself, giving 144.
