[https://www.youtube.com/watch?v=LueVHtL7eqM:embed:cite]
This explanation corresponds to ITPEC April 2025 FE (Fundamental IT Engineer) Subject B Q1 | Step-by-Step Explanation, and the correct answer is f. The central issue in this question is not merely knowing the leap-year rules, but implementing them correctly in a priority-driven if–elseif–else structure, where the first satisfied condition immediately determines the result. Because later branches are evaluated only if earlier branches fail, the ordering of conditions must reflect the hierarchy of the rules. If the order is wrong, the program can still appear logically sound while producing incorrect results for specific edge cases, especially centurial years. A leap year is determined by a set of rules that are intentionally hierarchical. The broad rule is that years divisible by 4 are leap years. However, there is a narrower exception: years divisible by 100 are not leap years. On top of that, there is an exception to the exception: years divisible by 400 are leap years after all. This layered structure is exactly what makes the ordering of conditions critical. If the program checks divisibility by 100 first and immediately returns false, it will incorrectly classify a year such as 2000 as a common year, even though it must be treated as a leap year. To avoid this mistake in an if–elseif–else chain, the most specific and overriding rule must be evaluated first. For this reason, option f assigns the condition year mod 400 = 0 to A and returns true in B. This first branch handles the highest-priority rule, often called the 400 rule, which overrides the centurial rule. When this condition is satisfied, the program terminates immediately with a true result. This behavior is essential, because it prevents the program from falling into later branches that would incorrectly reject the year. For example, the year 2000 is divisible by 400, by 100, and by 4. If the program were to test divisibility by 100 first, it would incorrectly return false. By testing divisibility by 400 first, the program correctly identifies 2000 as a leap year and stops further evaluation. If the program proceeds beyond the first condition, it is already known that the year is not divisible by 400. This context is important for interpreting the next rule. At this stage, the program must identify centurial years that should not be treated as leap years. These are years divisible by 100 but not by 400, such as 1900 or 2100. Therefore, option f places the condition year mod 100 = 0 into C and returns false in that branch. This ensures that such centurial years are correctly excluded. This check must appear before the general divisibility-by-4 rule, because many centurial years are divisible by 4. If the mod 4 condition were evaluated earlier, years like 1900 would be incorrectly classified as leap years. Only after both the 400 rule and the 100 rule have failed does the program evaluate the general case. At this point, the year is confirmed to be non-centurial. For these years, the leap-year decision is simple: if the year is divisible by 4, it is a leap year; otherwise, it is a common year. This logic is implemented by the condition year mod 4 = 0 returning true, followed by a final else branch that returns false when none of the conditions are met. The correctness of option f becomes clear when examining representative examples. A year like 2000 satisfies the first condition and is correctly classified as a leap year. A year like 1900 fails the first condition, satisfies the second, and is correctly classified as a common year. A year like 2024 fails the first two conditions, satisfies the third, and is correctly classified as a leap year. A year like 2023 fails all conditions and is correctly classified as a common year. All cases align perfectly with the leap-year definition. Many incorrect options fail because they place a general condition before an exception, or because they return the wrong value at the moment an exception is detected. Option f avoids these mistakes by arranging the conditions from most specific to most general and by returning the correct result at each decision point. In conclusion, option f is correct because it faithfully translates the hierarchical leap-year rules into a priority-based conditional structure. It first handles the overriding 400 rule, then applies the centurial exclusion rule, and finally evaluates the general divisibility-by-4 rule. This ordering ensures correct behavior for all years, including critical edge cases. For this reason, f is the correct answer for ITPEC April 2025 FE (Fundamental IT Engineer) Subject B Q1.