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

Actual exam question for ISTQB's CTAL-TTA exam
Question #: 33
Topic #: 6
[All CTAL-TTA Questions]

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?

Show Suggested Answer Hide Answer
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.

Contribute your Thoughts:

0/2000 characters
Elbert
3 months ago
Totally agree, A is the most critical issue here.
upvoted 0 times
...
Eileen
3 months ago
I think variable names could be clearer.
upvoted 0 times
...
Oliva
3 months ago
Imaginary roots? That's wild!
upvoted 0 times
...
Cordelia
4 months ago
Wait, does it really handle all edge cases?
upvoted 0 times
...
Justa
4 months ago
Definitely need to check for zero divisors!
upvoted 0 times
...
Janey
4 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.
upvoted 0 times
...
Goldie
4 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.
upvoted 0 times
...
Cristina
4 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.
upvoted 0 times
...
Melissa
5 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.
upvoted 0 times
...
Theodora
5 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.
upvoted 0 times
...
Chi
5 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.
upvoted 0 times
...
Alaine
5 months 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.
upvoted 0 times
...
Alida
5 months 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.
upvoted 0 times
...
Leota
11 months 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?
upvoted 0 times
Lisha
10 months ago
B) Are all variables properly defined with meaningful, consistent and clear names?
upvoted 0 times
...
Malika
11 months ago
B) Are all variables properly defined with meaningful, consistent and clear names?
upvoted 0 times
...
...
Joseph
11 months ago
Definitely need to test for those imaginary roots. Wouldn't want the program to crash if it encounters a negative discriminant!
upvoted 0 times
...
Anika
11 months ago
That's true, but I think ensuring divisors are tested for zero is more critical in this case.
upvoted 0 times
...
Armando
11 months ago
But what about option B? Properly defining variables is also important.
upvoted 0 times
...
Dorothea
11 months ago
I agree with Anika, testing divisors for zero is crucial in this program.
upvoted 0 times
...
Anika
11 months ago
I think option D is the most likely to indicate a problem.
upvoted 0 times
...
Catrice
12 months 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!
upvoted 0 times
Georgeanna
11 months ago
Definitely, it's better to catch potential errors early on.
upvoted 0 times
...
Jacquelyne
11 months ago
I agree, that's an important check to make in any program.
upvoted 0 times
...
Lettie
11 months ago
Always good to double check for division by zero, better safe than sorry!
upvoted 0 times
...
...

Save Cancel