← Build Systems & an Intro to CMake

Fix: One Definition Rule

medium

This file defines is_even twice, with two different (and disagreeing) implementations – one is correct, one has its condition backwards. C’s one-definition rule means a function may be defined exactly once per program; having two, even if one were correct, is a compile error regardless of which one you’d actually want to call.

Submit as-is, read the “redefinition of is_even” error, then fix the file so it contains exactly one definition of is_even – the correct one. This is the single-file version of the bug real header-based projects avoid by keeping function bodies out of headers entirely (as covered in the lesson): if a body lived in a header and two .c files included it, you’d get this exact error the moment both were compiled together.

Your solution

"Run" uses the sample stdin ("4"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution