ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 24 - CTAL-TTA discussion

Report
Export

Consider the following code segments.

Segment 1:

If a > b then setc = 12

elseif c >7 set c = 5

endif

Segment 2: setc= 12 for n = 1 to c

display c

endfor

Segment 3:

If (a > b) or (c < d) then

set c = 12

else

set c = 5

endlf

Segment 4:

set y = 4

call (segments)

segments:

start

for I = 1 to y

print y

endfor

end

Which segment would receive the highest cyclomatic complexity value?

A.
Segment 1
Answers
A.
Segment 1
B.
Segment 2
Answers
B.
Segment 2
C.
Segment 3
Answers
C.
Segment 3
D.
Segment 4
Answers
D.
Segment 4
Suggested answer: C

Explanation:

Cyclomatic complexity is a measure of the number of linearly independent paths through a program's source code. Segment 3 has two conditions: if (a > b) or (c < d) and the associated else. This structure introduces multiple decision points, thereby increasing the number of potential execution paths. Comparatively, the other segments have fewer conditions and straightforward loops, which contribute to a lower cyclomatic complexity. Segment 3, with its compound condition and branching logic, likely has the highest cyclomatic complexity.

asked 18/09/2024
Kefash White
38 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first