Match Pascal library functions to acceptable argument types or domains: (A) ROUND X, (B) ABS X, (C) SQR X, (D) SIN X — with: (1) X in radians, (2) X real, (3) X real or integer.

Difficulty: Easy

Correct Answer: A-2, B-3, C-3, D-1

Explanation:


Introduction / Context:
Classic Pascal provides standard functions with defined argument types. Knowing which functions accept integers, reals, or require angular input in radians is a common programming-language fundamentals topic.


Given Data / Assumptions:

  • ROUND(X) converts a real to the nearest integer.
  • ABS(X) returns absolute value; works for integer and real overloads.
  • SQR(X) returns the square; works for integer and real overloads.
  • SIN(X) expects an angle in radians.


Concept / Approach:
Check each function's signature in standard Pascal (e.g., Turbo Pascal, ISO Pascal) and match to the most general argument category presented in the options.


Step-by-Step Solution:

A (ROUND X) → X must be real (fractional allowed) → 2.B (ABS X) → X can be integer or real (overloaded) → 3.C (SQR X) → valid for integer or real (overloaded) → 3.D (SIN X) → X is an angle in radians for trigonometric functions → 1.


Verification / Alternative check:
In many Pascal dialects: 'ROUND: real → integer; ABS: same type out; SQR: same type out; SIN: real in radians → real.' Example: SIN(pi/2) = 1.0 when X is in radians.


Why Other Options Are Wrong:

  • A-2, B-3, C-1, D-3: Assigns SQR to radians and makes SIN accept integer/real nonsensically.
  • A-3, B-2, C-2, D-1: Claims ROUND accepts integer, which defeats its purpose.
  • A-2, B-3, C-2, D-1: Narrows SQR to reals only; it also works for integers.


Common Pitfalls:

  • Feeding degrees into SIN without converting to radians.
  • Expecting ROUND to accept integers (it is for rounding reals).


Final Answer:
A-2, B-3, C-3, D-1

More Questions from Matching Questions

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion