One-page version suitable for printing.
Using the following method, what are the values of the following expressions?
public static int f(int x) { int y = 4 * x; if(y < 10) return y; y++; return y / 6; }
a. | 15 - 1 - 3 * 2 |
---|---|
b. | 15 - 12 % 5 |
c. | f(1) |
d. | f(f(4)) |
Consider the following method to compute the greatest common denominator of two numbers.
public static int gcd(int m, int n) { int r; while(m != 0) { r = m % n; m = n; n = r; } return m; }
r m 42 n 54
Fill in run() so that the method will print ``Hello'' to the screen 2,001 times.
import csbsju.cs160.*; public class PrintHello { public static void run() { } }
Say we've defined the following method.
public static int f(int x) { IO.print(x); return x * 2; }