cybersecurity · beginner · ~15 min · safe pentest lab

Number of ports to scan

Compute an inclusive range size.

Challenge

Implement int port_count(int lo, int hi) returning how many ports are in the inclusive range [lo, hi], or 0 if hi < lo.

Starter code

int port_count(int lo, int hi) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.