


















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















































A. x > 10 AND x < 10 B. x != 10 C. x >= 10 AND x <= 10 D. x < 10 OR x > 10 Answer: C. x >= 10 AND x <= 10 Rationale: The expression requires x to be both at least 10 and at most 10. Therefore, the only possible value satisfying both conditions is exactly 10. The other expressions either exclude 10 or cannot be true when x equals 10.
A. To specify the exact syntax of a programming language B. To provide a finite sequence of steps for solving a problem C. To determine the hardware architecture of a computer D. To replace the need for testing Answer: B. To provide a finite sequence of steps for solving a problem Rationale: An algorithm describes a logical procedure for accomplishing a task or solving a problem. It is independent of the syntax of a particular programming language and can later be implemented using code.
Answer: A. 7 Rationale: Zero-based indexing begins with index 0. Therefore, an array containing eight elements has indexes 0 through 7. The final element is consequently located at index 7.
A. Using a Boolean variable to represent true or false B. Starting an array traversal at index 0 but iterating one position beyond its final index C. Assigning a string to a string variable D. Calling a function with two correctly typed arguments Answer: B. Starting an array traversal at index 0 but iterating one position beyond its final index Rationale: Off-by-one errors occur when a loop or calculation includes one position too many or too few. Array boundaries are a common source because programmers must correctly account for whether indexing begins at zero and where the final valid index occurs.
Answer: C. Floating-point Rationale: The value contains a fractional component and therefore cannot be represented as an ordinary integer without losing information. Floating-point data types are designed to represent numbers containing decimal portions.
z = 2 result = x + y * z What is the value of result? A. 22 B. 18 C. 30 D. 24 Answer: A. 22 Rationale: Multiplication has precedence over addition. Therefore, y * z is evaluated first: 7 × 2 = 14. Then 4 + 14 = 18. Wait—the correct calculation is 18 , so the correct answer is B. The key concept is operator precedence: multiplication occurs before addition.
constants instead of repeatedly embedding literal values improves readability and reduces accidental modification.
Rationale: A switch or case construct evaluates an expression and selects an appropriate branch from multiple predefined cases. It is particularly useful when comparing one value against several discrete possibilities.