Unit#1 Basic Elements of a C++ Program | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Constants and Variables
|
||||||||||||||||||||||||||||||||
The following numbers represent various constants that can be used in C++ programs:
The last two numbers are written in scientific notation. The last number corresponds to 0.00741 If you read your book carefully and if you went over the material presented in the previous subsection you must know by now that statements like: int scoresNumber; double width; float a2; are called declarations of variables. The names of the variables are ScoresNumber, width, a2, and their types are int (for integer), double, float. A declaration of a variable notifies the compiler to set aside space in memory where a value will be stored later. The name of the variable serves as the address of this memory space, the type of the variable defines the size of the memory and also the storage method. Rules about names: You can use letters, digits and the underscore character. The name cannot start with a digit. Lower case letters are different from upper case letters ( Examine the ASCII code table in the appendix of your book).
Data types :
There are many more types and we suggest that you look at your book for details. Also read your book and explain what is meant by precision and range. All data has to be first translated into binary representation and then stored in the form of a sequence of zeros and ones ( the bits). Since the number of bits is finite precision and range compete for space. Try to understand this issue well. Another issue you must understand is the representational error and other numeric errors such as arithmetic overflow, arithmetic underflow, and cancellation error. |
||||||||||||||||||||||||||||||||
Jacob
Y. Kazakia © 2001 All rights reserved
|