ITPEC FE Subject B April 2026 Question 6

From the answer group below, select the correct combination of answers to be inserted into A and B in the program.

The quadratic equation a1x2 + b1x + c1 = 0 can be formulated as x2 − 2(−b1/2a1) + (c1/a1) = 0 , where a1 ≠ 0 . If we replace (−b1/2a1) and (c1/a1) by b and c respectively, it can be further formulated as x2 − 2bx + c = 0, and the roots are as follows:
Case 1: if b2 − c = 0, double root b,

Case 2: if b2 − c > 0, two real roots b ± √b2 − c,

Case 3: if b2 − c < 0, two imaginary roots b ± i√c − b2, where i = √−1.

The procedure quadEquation takes the coefficients of a quadratic equation in arguments a1, b1, and c1 and uses the above formula to determine and output the roots. Here, a1 is not 0 and function sqrt returns the principal square root of its non-negative argument.

[Program]
○ quadEquation(real: a1, real: b1, real: c1)
real: b ← -b1 ÷ (2 × a1)
real: c ← c1 ÷ a1
real: val ← b × b - c
real: tmp
if (val = 0)
output "root1=root2=", A
elseif (val > 0)
tmp ← sqrt(val)
output "root1=", b + tmp
output "root2=", b - tmp
else
tmp ← B
output "root1=", b, "+", tmp, "i"
output "root2=", b, "-", tmp, "i"
endif

Answer group

OptionAB

Explanation

A: b, B: sqrt(-val) — b already carries the minus sign, and in the imaginary case the square root is taken of −val, which is positive there.

The program uses the normalised form x2 − 2bx + c = 0: b is −b1 ÷ (2 × a1), c is c1 ÷ a1, and val is b2 − c.

  • •A, Case 1 (val = 0): the double root is b, so the output is b
  • •B, Case 3 (val < 0): the roots are b ± i√c − b2. Since c − b2 is −val, a positive number here, tmp must be sqrt(-val); the program prints the i itself

Example: x2 − 2x + 5 = 0 gives b = 1, c = 5, val = −4 and tmp = 2, so the output is the roots 1 + 2i and 1 − 2i.

Answer (d)

Why not others:

  • •(a) and (b) — output -b for the double root; the minus is already in the definition of b, so negating it again gives a root of the wrong sign
  • •(a) and (c) — use -sqrt(val); val is negative in this branch and sqrt accepts only a non-negative argument, so the minus has to go inside the call, not outside

Key rule: Before filling a branch, check the sign of every quantity in it; the square root of a negative discriminant is written as i times the root of its negation.

Math & Numbers · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.