Workshop
The Workshop provides quiz questions to help you solidify your understanding of the material covered and exercises to provide you with experience in using what you’ve learned. Try to answer the quiz and exercise questions before checking the answers in Appendix D, and be certain that you understand the answers before continuing to the next lesson.
Quiz
1. |
What is the difference between the compiler and the preprocessor? |
2. |
Why is the function main() special? |
3. |
What are the two types of comments and how do they differ? |
4. |
Can comments be nested? |
5. |
Can comments be longer than one line? |
Exercises
1. |
Write a program that writes I love C++ to the console. |
2. |
Write the smallest program that can be compiled, linked, and run. |
3. |
BUG BUSTERS: Enter this program and compile it. Why does it fail? How can you fix it? 1: #include <iostream> 2: main() 3: { 4: std::cout << Is there a bug here?"; 5: } |
4. |
Fix the bug in Exercise 3 and recompile, link, and run it. |
5. |
Modify Listing 2.7 to include a subtract function. Name this function Subtract() and use it in the same way that the Add() function was called. You should also pass the same values that were passed to the Add() function. |