// function prototypes int ShellGame(int x, int y, int z); void main() { //Problem 1---------------------- cout << "Problem 1" << endl; int A = 3, B = 17; if (A == B) { cout << "same" << endl; if (A < B) cout << "in order" << endl; } else cout << "reversed" << endl; if (A == B) { cout << "same" << endl; } if (A < B) cout << "in order" << endl; else cout << "reversed" << endl; cout << endl; //Problem 2---------------------- cout << "Problem 2" << endl; cout << ShellGame( 3, 5, 4) << endl; cout << ShellGame( 4, 5, 3) << endl; cout << ShellGame( 5, 4, 3) << endl; cout << endl; } // end main int ShellGame(int x, int y, int z) { if (x < y) if (z < x) return x; else return x; else if (z < y) return y; else return z; }
Problem 3.
Write a C++ function that takes an integer argument N > 0 and returns the smallest integer K such that 2K >= N.
Problem 4.
Write a C++ function that takes integer arguments X and Y and returns true if X is between Y and 2*Y.