Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Notes on this paper
04-Soft-A6, Software Quality Assurance — National Exams, May 2016 (3 hours, open book, 8 questions of equal value; the first FIVE as they appear in the answer book are marked — all eight are solved here as a study resource).
Given. The unit under test is the Appendix A main function's nested-if leap-year logic: three sequential decisions — year % 4 == 0, then (nested inside it) year % 100 == 0, then (nested inside that) year % 400 == 0 — each guarding one of four printf outcomes.
Find. The cyclomatic complexity V(G) of the unit, and a minimal basis path testing suite of V(G) independent test cases (one input year each) that together execute every independent path through the control-flow graph.
Control-flow graph of the leap-year unit. Node 1: read year. Node 2: year%4==0. Node 3: year%100==0. Node 4: year%400==0. Node 5: print "leap" (400 true). Node 6: print "not leap" (400 false). Node 7: print "leap" (100 false — divisible by 4, not by 100). Node 8: print "not leap" (4 false). Node 9: exit. Nodes 2, 3 and 4 are the three predicate (decision) nodes.
Approach. Draw the flow graph of the triple-nested decision, compute V(G) two independent ways (they must agree), then derive V(G) independent basis paths — flipping one prior decision outcome at a time from a baseline — and pick the classic century-year test inputs that force each path.
Build the flow graph and count nodes/edges. Nine nodes (1: read; 2,3,4: the three nested decisions; 5,6,7,8: the four printf outcomes; 9: exit) and eleven edges: 1→2; 2→3(T); 2→8(F); 3→4(T); 3→7(F); 4→5(T); 4→6(F); 5→9; 6→9; 7→9; 8→9.
Compute V(G) two independent ways.
$$V(G) = E - N + 2 = 11 - 9 + 2 = \boxed{4}$$
$$V(G) = 1 + \sum_{\text{predicates}}(\text{out-degree}-1) = 1 + (2-1) + (2-1) + (2-1) = \boxed{4}$$
Both formulas agree at V(G) = 4, matching the three nested binary decisions (each predicate node contributes one extra independent path). Exactly 4 basis-path test cases are required.
Path 1: not divisible by 4 (nodes 1-2-8-9). The outer decision alone determines the outcome, both inner decisions are never reached.
Input: year = 2015 → 2015 % 4 = 3 ≠ 0 → Expected output: "2015 is not a leap year."
Path 2: divisible by 4, not by 100 (nodes 1-2-3-7-9). An ordinary (non-century) leap year — the inner %400 test is never reached.
Input: year = 2016 → 2016 % 4 = 0, 2016 % 100 = 16 ≠ 0 → Expected output: "2016 is a leap year."
Path 3: divisible by 4, 100 and 400 (nodes 1-2-3-4-5-9). A century year that IS a leap year — all three decisions are true.
Input: year = 2000 → 2000 % 4 = 0, 2000 % 100 = 0, 2000 % 400 = 0 → Expected output: "2000 is a leap year."
Path 4: divisible by 4 and 100, not 400 (nodes 1-2-3-4-6-9). A century year that is NOT a leap year — the case the algorithm exists specifically to catch (a naive "divisible by 4" check alone would wrongly call this a leap year).
Input: year = 1900 → 1900 % 4 = 0, 1900 % 100 = 0, 1900 % 400 = 300 ≠ 0 → Expected output: "1900 is not a leap year."
Basis-path test suite for the leap-year unit
Path
Nodes traversed
Input year
Expected output
1
1-2-8-9
2015
"2015 is not a leap year."
2
1-2-3-7-9
2016
"2016 is a leap year."
3
1-2-3-4-5-9
2000
"2000 is a leap year."
4
1-2-3-4-6-9
1900
"1900 is not a leap year."
Check: assumes normal numeric console input for year — a full test plan would add a robustness case for non-numeric scanf input, which is a black-box/error-handling concern (Q7's technique) outside the 4 basis paths of the arithmetic decision logic itself.