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 make sure that you understand the answers before continuing to the next chapter.
Quiz
1. What is the difference between an integer variable and a floating-point variable?
2. What are the differences between an unsigned short int and a long int?
3. What are the advantages of using a symbolic constant rather than a literal constant?
4. What are the advantages of using the const keyword rather than #define?
5. What makes for a good or bad variable name?
6. Given this enum, what is the value of BLUE?
enum COLOR { WHITE, BLACK = 100, RED, BLUE, GREEN = 300 };
7. Which of the following variable names are good, which are bad, and which are invalid?
- Age
- !ex
- R79J
- TotalIncome
- __Invalid
Exercises
-
What would be the correct variable type in which to store the following information?
- Your age.
- The area of your backyard.
- The number of stars in the galaxy.
- The average rainfall for the month of January.
-
Create good variable names for this information.
-
Declare a constant for pi as 3.14159.
Declare a float variable and initialize it using your pi constant.