October 13, 2023
October 13, 2023
October 13, 2023
###### Data-Communication
October 13, 2023
 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

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