Question 1 of 10
A math library documents: sqrt(x) returns the nonnegative square root of x for x ≥ 0. Which call matches that documentation to store the square root of 49 in r?
- A. r ← sqrt(49)
- B. r ← sqrt(49, 49)
- C. sqrt(49) ← r
- D. r ← sqrt
A math library documents: sqrt(x) returns the nonnegative square root of x for x ≥ 0. Which call matches that documentation to store the square root of 49 in r?
A text library documents: concat(a, b) returns a single string formed by placing b immediately after a. Which call produces "APCSP"?
Why does using a documented library procedure help when building a larger program?
A robotics library documents: moveForward(steps) moves the robot steps units forward and returns the new odometer reading. The robot starts at odometer 0. Which sequence ends with odometer 7?
An API entry reads: max(a, b) returns the larger of a and b. Which call returns 12?
A graphics library documents drawRect(x, y, w, h) as drawing a rectangle with top-left (x, y), width w, and height h. It returns nothing. Which call matches the documentation to draw a 10-by-4 rectangle at (2, 3)?
The table is an excerpt from a string library API.
| Procedure | Parameters | Returns |
|---|---|---|
| length(s) | s: string | number of characters in s |
| charAt(s, i) | s: string; i: 1-based index | the character at position i |
Which call returns the character "C" from s ← "CSP"?
A student needs the greatest common divisor of two integers. A library already provides gcd(a, b). What is the best next step?
A time library documents: toMinutes(h, m) returns 60 * h + m. Which expression equals 125 minutes?
Documentation for clamp(n, lo, hi) says it returns n limited to the closed interval from lo to hi. Which call returns 10 when n would otherwise be 15?