// 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, 4, 5) << endl; cout << ShellGame( 4, 3, 5) << endl; cout << ShellGame( 5, 3, 4) << 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 sum of the first N squares. (1 + 4 + 9 + ... + N*N)
Problem 4.
Write a C++ function that takes integer arguments X and Y and returns true if the point
(X, Y) lies in the tiny drawing window, false otherwise. (The window corners are (0, 0) and (200, 200).)