Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

ISTQB CTAL-TTA Exam - Topic 6 Question 33 Discussion

Posted by Dewitt on Mar 19, 2025 at 12:40 AM

Given the following pseudo code for a program to solve quadratic equations:

program Quadratic Formula

integer: a, b, c, d

floating point: r1, r2

READ (a)

READ (b)

READ (c)

d := (b * b) - (4 * a * c)

IF d < 0 THEN

PRINT ("Imaginary Roots")

ELSE

r1 := (-b + sqrt(d)) / (2 * a)

r2 := (-b - sqrt(d)) / (2 * a)

PRINT ("first root is: " r1)

PRINT ("second root is: " r2)

ENDIF

END program Quadratic_Formula

Which of the following checklist items is MOST likely to indicate a problem in this program?

Suggested Answer: D

Analysis:

The given pseudo code for solving quadratic equations includes operations that involve division. One of the critical issues in such operations is ensuring that the divisor is not zero, which would result in a division by zero error.

Checklist Item:

D . Are divisors tested for zero or noise?:

This checklist item addresses the potential problem of dividing by zero. In the pseudo code, the variable a is used as a divisor in the formula (-b sqrt(d)) / (2 * a). If a is zero, this will result in a division by zero error. Therefore, it is crucial to test whether a is zero before performing the division.

Explanation of Incorrect Options:

A . Does the code avoid comparing floating point numbers for equality?:

This is important but not directly relevant to the given pseudo code's primary issue.

B . Are all variables properly defined with meaningful, consistent and clear names?:

This is good practice but does not address the critical issue of division by zero.

C . Are there any redundant or unused variables?:

Identifying unused variables is helpful for code clarity but does not address the primary functional issue in the pseudo code.


The ISTQB CTAL-TTA syllabus and standard code review practices emphasize the importance of ensuring safe arithmetic operations, particularly avoiding division by zero.

Sources:

ISTQB-CTAL-TTA Syllabus

General knowledge on code review and arithmetic operations.

Get Premium CTAL-TTA Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
25 comments · newest first
EL
Elbert 10 months ago
Totally agree, A is the most critical issue here.
EI
Eileen 10 months ago
I think variable names could be clearer.
OL
Oliva 10 months ago
Imaginary roots? That's wild!
CO
Cordelia 10 months ago
Wait, does it really handle all edge cases?
JU
Justa 11 months ago
Definitely need to check for zero divisors!
JA
Janey 11 months ago
Option D stands out to me because I recall that dividing by zero can cause errors, so it’s crucial to test for that in any program.
GO
Goldie 11 months ago
I’m a bit confused about option C; I don’t see any unused variables, but I guess it’s worth double-checking.
CR
Cristina 11 months ago
I remember practicing a question about variable naming conventions, so option B seems relevant, but I feel like the names here are pretty straightforward.
ME
Melissa 12 months ago
I think option A might be a concern since comparing floating point numbers can lead to inaccuracies, but I'm not entirely sure how it applies here.
TH
Theodora 12 months ago
Comparing floating-point numbers for equality is always tricky, so that's probably the most likely issue to watch out for. I'd spend some time thinking through how to handle that properly.
CH
Chi 12 months ago
The code looks good overall, but I'd be sure to test the edge cases, like when the discriminant is exactly 0. Gotta make sure we're handling all possible scenarios.
AL
Alaine 1 year ago
Hmm, the variable names seem clear enough, but I'd double-check that they're all being used consistently throughout the code. Wouldn't want any typos or unused variables.
AL
Alida 1 year ago
This looks like a pretty straightforward quadratic equation solver. I'd focus on checking for potential division by zero and handling imaginary roots properly.
LE
Leota 1 year ago
Hmm, the variable names could use some work. 'a', 'b', and 'c' are a bit cryptic. How about 'coefficient_a', 'coefficient_b', and 'constant_c' instead?
LI
Lisha 1 year ago
↳ replying to Leota
B) Are all variables properly defined with meaningful, consistent and clear names?
MA
Malika 1 year ago
↳ replying to Leota
B) Are all variables properly defined with meaningful, consistent and clear names?
JO
Joseph 1 year ago
Definitely need to test for those imaginary roots. Wouldn't want the program to crash if it encounters a negative discriminant!
AN
Anika 1 year ago
That's true, but I think ensuring divisors are tested for zero is more critical in this case.
AR
Armando 2 years ago
But what about option B? Properly defining variables is also important.
DO
Dorothea 2 years ago
I agree with Anika, testing divisors for zero is crucial in this program.
AN
Anika 2 years ago
I think option D is the most likely to indicate a problem.
CA
Catrice 2 years ago
The program looks good, but I would check for division by zero just to be safe. Don't want any unexpected errors cropping up!
GE
Georgeanna 1 year ago
↳ replying to Catrice
Definitely, it's better to catch potential errors early on.
JA
Jacquelyne 1 year ago
↳ replying to Catrice
I agree, that's an important check to make in any program.
LE
Lettie 1 year ago
↳ replying to Catrice
Always good to double check for division by zero, better safe than sorry!
0/2000 characters

Save Cancel