...
Nielit Scientist-B IT 22-07-2017
October 13, 2023
Data-Communication
October 13, 2023
Nielit Scientist-B IT 22-07-2017
October 13, 2023
Data-Communication
October 13, 2023

Software-Engineering

Question 434
Consider the following C program segment.
while (first <= last)
{
if (array[middle] < search)
first = middle + 1;
else if (array[middle] == search)
found = TRUE;
else last = middle – 1;
middle = (first + last)/2;
}
if (first < last) not Present = TRUE;
The cyclomatic complexity of the program segment is_______.
A
3
B
4
C
5
D
6
Question 434 Explanation: 
some coaching institutes are giving B as the correct answer.
To find the cyclomatic complexity using three formulas.
1. The number of regions
2. Predicate(P) + 1 [ Predicate divides minimum 2 or more ]
3. E-V+2
According to given question, we can use Predicate(P) + 1
while (first <= last) → P1
{
if (array[middle] < search) → P2
first = middle + 1;
else if (array[middle] == search) → P3
found = TRUE;
else
last = middle – 1;
middle = (first + last)/2;
}
if (first < last) not Present = TRUE; → P4

→ P+1 = 4+1 = 5

Correct Answer: C
Question 434 Explanation: 
some coaching institutes are giving B as the correct answer.
To find the cyclomatic complexity using three formulas.
1. The number of regions
2. Predicate(P) + 1 [ Predicate divides minimum 2 or more ]
3. E-V+2
According to given question, we can use Predicate(P) + 1
while (first <= last) → P1
{
if (array[middle] < search) → P2
first = middle + 1;
else if (array[middle] == search) → P3
found = TRUE;
else
last = middle – 1;
middle = (first + last)/2;
}
if (first < last) not Present = TRUE; → P4

→ P+1 = 4+1 = 5

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!