Test is tomorrow Today: Review over arrays, functions, void, call-by-reference, ?, ?, ?, ?, material: ch 8 - 13 for, switch, functions, enums, arrays char char; cout << direction; switch (direction) { case 'n': cout << "to lazy to hit the shiftkey?"; case 'N': cout << "You are going north!"; break; case 's': case 'S': cout << "You are going south!"; break; default: cout << "Thats not a valid direction!"; } for (int i=0;i<5;i++) { cout << i << " "; } 0 1 2 3 4 enum directionType { north, south, east, west}; directionType direction; cout << "Give me a direction" << endl; cout << "0..north" << endl; cout << "1..south" << endl; //... int i; cin >> i; direction = static_cast(i); if (direction == north) { ... } switch (direction) { case north: cout << "North"; break; case south: cout << "South"; break; case east: cout << "East"; break; } void maxIsGreat(); int main() { maxIsGreat(); return 0; } void maxIsGreat() { cout << "Max is Great!" << endl; } void someoneGreat(string who, string what); int main() { someoneGreat("smart", "Max"); return 0; } void someoneGreat(string who, string what) { cout << who << " is " << what << "!" << endl; } void printAB(int a, int b) { cout << a << " " << b; } int main() { int a = 7; int b = 10; printAB(b,a); ... int multiplyAB(int a, int b) { return a*b; } int main() { int a = 7; int b = 10; cout << multiplyAB(b,a); int c = multiplyAB(b,a); ... float division(int a, int b) { return static_cast(a)/b; } void fight(int &hp_good, int &hp_bad) { // some calculation hp_good-=1; hp_bad-=10; } ... fight(hpa,hpb); ... int a[20], b[20]; a = {1,2,3 }; // does NOT work!!!!! b = a; /// does NOT work!!!!!! int c[4] = {1,6,3,5}; // Initialize int d[4] = {1,2,3,4,5,6}; // does NOT work! int e[20] = {1,2,3,4,5}; // works! // initializiliase rest to 0! int f[] = {1,2,3,4}; // array of size 4 int g[20] = {0}; // all set to 0 int h[]; // works, but we're not there yet! cout << c[2]; e[6] = 12; for (int i=0;i<4;i++) { cout << c[i] << " "; } int j[100]; for (int i=0;i<100;i++) { j[i] = i+1; } int k[10]; k[0] = 1; k[1] = 1; for (int i=2;i<10;i++) { k[i] = k[i-2]+k[i-1]; } 0 1 2 3 4 5 6 7 8 9 1 1 2 3 5 8 13 int a[10]; for (int i=0;i<10;i++) { a[i] = i+1; } for (int i=0;i<10;i++) { a[i] = a[9-i]; } 0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 6 7 8 9 10