// ============================================ // Introduction (p. 7) #include using namespace std; int main() { cout << "Hello World! \n"; return 0; } // ============================================ // Introduction (p. 15) cout << "Hello World! \n"; cout << "I love C++\n so much!"; cout << "Hello World! \n" << "I love C++\n so much!"; // ============================================ // Introduction (p. 27) #include using namespace std; int main() { int num1 = 13, num2 = 4; cout << num1 + num2; return 0; } // ============================================ // Introduction (p. 32) #include using namespace std; int main() { int num1 = 13, num2 = 4; cout << "The sum of " << num1 << " and " << num2 << " is " << num1 + num2 << "\n"; return 0; } // ============================================ // Introduction (p. 33) #include using namespace std; int main() { int num1 = 13, num2 = 4; cout << num1 + num2 << "\n"; cout << num1 - num2 << "\n"; cout << num1 * num2 << "\n"; cout << num1 / num2 << "\n"; cout << num1 % num2 << "\n"; return 0; } // ============================================ // Introduction (p. 34) #include using namespace std; int main() { int num1 = 0, num2 = 0; cout << "Please enter one number: "; cin >> num1; cout << "Please enter another number: "; cin >> num2; cout << "The sum is " << num1 + num2; return 0; } // ============================================ // Introduction (p. 37) #include using namespace std; int main() { int num1 = 0, num2 = 0; cout << "Please enter two numbers, separated by a white space: "; cin >> num1 >> num2; cout << "The sum is " << num1 + num2; return 0; } // ============================================ // Introduction (p. 39) #include using namespace std; int main() { int num1 = 0, num2 = 0; cout << "Please enter two numbers, " << "separated by a white space: "; cin >> num1 >> num2; if (num1 > num2) cout << "The larger one is " << num1; if (num1 < num2) cout << "The larger one is " << num2; if (num1 == num2) cout << "The two are equal"; return 0; } // ============================================ // Introduction (p. 43) #include using namespace std; int main() { int num1 = 0, num2 = 0; cout << "Please enter two numbers, " << "separated by a white space: "; cin >> num1 >> num2; while (num1 > num2) { cout << "number 1 is " << num1 << "\n"; num1 = num1 - 1; } return 0; }