logo CodeStepByStep logo

if_else_mystery0

Language/Type: PHP if/else

For each call to the following function, indicate what output is produced.

function if_else_mystery0($n) {
    print("$n ");
    if ($n > 0) {
        $n = $n - 5;
    }
    if ($n < 0) {
        $n = $n + 7;
    } else {
        $n = $n * 2;
    }
    print("$n\n");
}
mystery(8);
mystery(-3);
mystery(1);
mystery(0);

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.