id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

Warmup 2Close10

prev  |  next  |  chance
public static int close10(int a, int b) {
    if (Math.abs(10 - a) > Math.abs(10 - b))
        return b;
    else if (Math.abs(10 - a) < Math.abs(10 - b))
        return a;
    else
        return 0;
}
Function Call  Return Value
close10(3, 3)
close10(8, 10)
close10(10, 21)
close10(40, 2)
close10(4, 2)

Experiment with this code on Gitpod.io

⬅ Back