Software Metrics & Measurement MCQs for NSCT
Software metrics put numbers on software and the process that builds it: size (LOC, function points), complexity (cyclomatic complexity), quality (defect density) and productivity. It is topic 13 of the Software Engineering area, which carries 10% of the NSCT according to HEC's Areas of Competencies. In 2026 candidates averaged 50.1% in Software Engineering, per the HEC NSCT report and APP.
Most questions here are short calculations, so learn each formula with one worked number. Metrics also feed estimation in Software Project Management and test planning in Software Testing.
LOC
Lines of code (LOC) is a direct size measure: you count it straight from the source. It is usually quoted in KLOC (thousands of lines) and used to normalise other measures.
| Metric | Formula | Example |
|---|---|---|
| Productivity | LOC ÷ person-months | 30,000 LOC by 5 people in 6 months = 1,000 LOC/PM |
| Defect density | Defects ÷ KLOC | 45 defects in 15 KLOC = 3 per KLOC |
| Cost per LOC | Cost ÷ LOC | 4.5 million rupees ÷ 30,000 = 150 rupees per line |
LOC is easy to collect but depends on the language and on counting rules (comments, blank lines, generated code), and it is only known after coding. Pressman calls LOC and execution speed direct measures, while quality attributes such as maintainability are indirect. Exam angle: LOC productivity penalises high-level languages, because the same feature takes fewer lines in Python than in assembly.
Function points
Function points (FP), from Albrecht and now IFPUG, measure delivered functionality from the user's view. You count five function types and weight each one by complexity.
| Type | Meaning | Simple / Average / Complex |
|---|---|---|
| EI, external input | Data entering the boundary | 3 / 4 / 6 |
| EO, external output | Output with calculation or derived data | 4 / 5 / 7 |
| EQ, external inquiry | Retrieval with no derived data | 3 / 4 / 6 |
| ILF, internal logical file | Data the system maintains | 7 / 10 / 15 |
| EIF, external interface file | Data read from another system | 5 / 7 / 10 |
The weighted sum is the unadjusted count (UFP). Fourteen general system characteristics are each rated 0 to 5, and VAF = 0.65 + 0.01 × ΣFi, so VAF runs from 0.65 to 1.35. Then FP = UFP × VAF.
Example: 6 average EIs, 3 average EOs and 2 average ILFs give UFP = 24 + 15 + 20 = 59. With ΣFi = 45, VAF = 1.10 and FP = 64.9. Exam angle: FP can be counted from requirements and does not depend on the language, which is why it suits early estimation and cross-language comparison.
Cyclomatic complexity
McCabe's cyclomatic complexity V(G) counts the linearly independent paths through a module's control flow graph. Three equivalent formulas:
- V(G) = E − N + 2P (edges, nodes, connected components)
- V(G) = number of binary decisions (predicate nodes) + 1
- V(G) = number of regions of a planar flow graph
def fee(units, member):
if units > 100: # decision 1
rate = 8
else:
rate = 10
for _ in range(3): # decision 2
if member: # decision 3
rate -= 1
return rate * units
Three decisions give V(G) = 4, so basis path testing needs four test cases. Else, return and break add no decisions. When a condition uses and/or, Pressman counts each simple condition separately; some tools count the whole if once, so read the question's rule. Exam angle: McCabe suggested reviewing any module above 10.
Other metrics you should recognise
- Halstead: vocabulary n = n1 + n2 (distinct operators and operands), length N = N1 + N2, volume V = N × log2 n.
- CK metrics for object-oriented code: WMC, DIT (inheritance depth), NOC (children), CBO (coupling), RFC and LCOM (lack of cohesion).
- Quality: defect removal efficiency DRE = E ÷ (E + D), where E is defects found before release and D after. Availability = MTTF ÷ (MTTF + MTTR).
- GQM: set a Goal, ask Questions, then pick Metrics, in that order.
Measurement scales matter too: defect category is nominal, severity is ordinal, and LOC is a ratio scale.
Common traps
- Forgetting the + 2 in E − N + 2P, or the + 1 in decisions + 1.
- Treating 1 as the lowest VAF; the range is 0.65 to 1.35.
- Comparing raw defect counts instead of defects per KLOC.
- Dividing LOC by months or by people instead of person-months.
- Confusing EQ (no derived data) with EO (calculations or derived data).
- Counting return or break as extra decisions in V(G).
Worked examples
Understanding. Which function point type covers a customer master file that another company's system maintains and yours only reads? Answer: an external interface file (EIF). Your application references it but does not maintain it. If your system updated it, it would be an internal logical file.
Application. A flow graph has 14 edges and 11 nodes in one component. What is V(G)? Answer: 5. V(G) = 14 − 11 + 2 = 5, so a basis set has five independent paths.
Analysis. Before release, testing found 76 defects; customers then reported 4. A second project found 50 before release and 10 after. Which team removed defects more effectively? Answer: the first. DRE = 76 ÷ 80 = 95% against 50 ÷ 60 ≈ 83%. The second team let a larger share of its defects escape, even though it reported fewer in total.
Practise
The quiz below has 100 Software Metrics & Measurement questions, which you can filter by tier and difficulty.
Practise: 100 questions
FAQs
Is cyclomatic complexity the same as the number of test cases?
It is the number of test cases needed to cover a basis set of independent paths in basis path testing. Branch coverage can often be reached with fewer tests, and some paths may be infeasible, so treat V(G) as the target for basis path testing rather than a universal test count.
Why are function points preferred over LOC for estimation?
You can count function points from the requirements before any code exists, and the count does not change with the programming language. LOC is only known after coding and rewards verbose languages. The trade-off is that FP counting needs training and some judgement about complexity.
What is a good defect density?
There is no single standard figure; it depends on the domain, the language and how defects are counted. Use defect density to compare modules or releases inside the same organisation, and investigate modules well above the local average first.
What is the difference between a metric and a measure?
A measure is a raw number, such as 12 defects or 4,000 LOC. A metric relates measures to give insight, such as 3 defects per KLOC. Pressman uses this distinction, though many texts use the words interchangeably.
Next step
Continue with Software Configuration Management MCQs, go back to the Software Engineering hub, or try a timed NSCT mock test.