Now that you've had the chance to try variables and constants, you can answer a few questions and do a couple of exercises to firm up your knowledge of the compiler.
Why would you use unsigned over signed integers?
What is the difference between initialization and defining a variable?
Are the variables DOG, dog, Dog, and doG the same?
What is the difference between a #define constant and const?
Expand the program in Listing 3.1 to include all the variable types shown in Table 3.1. Your values may be the same or differ from those shown.
Think about some of the numbers and information you see around you in daily lifeand the type of variable that would be best to hold them. Think of meaningful variable names for them.
If you have access to professional software developers, ask them their preferred variable naming format. If you have access to several of them, you will find that they have different approaches. Ask them "why?" You may be surprised at the answers you get.
Unsigned integers allow you to count more positive values than signed. They will also not take any negative values. It is up to you as a programmer to determine which is best for the problem you are trying to solve.
Definition is when you declare the data type and name of a variable. Initialization is the assignment of the first (or initial) value to it. Both definition and initialization can take place in the same command.
No, they are not. C++ is case sensitive and each spelling looks like a different variable to the compiler. It is a matter of personal or group choice what form the names should take.
The preprocessor directive #define substitutes the specified value (literal constant) into your code every place it is used. A variable declared to be const occupies one location and has the specified data type.