Discussion
Consider the following pseudo-code :
If (A > B) and (C > D) then
A = A + 1
B = B + 1
EndifThe cyclomatic complexity of the pseudo-code is
Answer: B
The cyclomatic complexity of a piece of code is the number of decisions plus one. The pseudo-code has a single if statement whose condition is made of two simple conditions joined by 'and', and each simple condition counts as a decision, so there are two predicates and the complexity is 2 + 1 = 3, option (B). Counting only the whole if as one decision would give 2, and the larger values count decisions that are not there.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development