What does the flowchart look like?
Ready to draw?
No signup. Opens instantly in your browser.
What is the matching code?
Pseudocode
read n
if n is divisible by 2 then even
else oddPython
def even_or_odd(n):
if n % 2 == 0:
return "even"
return "odd"C
const char *even_or_odd(int n) {
if (n % 2 == 0) return "even";
return "odd";
}- Zero is even, because 0 divided by 2 has remainder 0.
- The diamond asks whether the remainder of dividing n by 2 is 0.