C++ Notes
Sample Code
Data Types
| Data Type |
Range |
Notes |
| bool |
1,-1 or 0 |
Boolean (ordinal).True for any non-zero value |
| char |
-128 to 127 |
Character (ordinal). Any single character. Any constant form enclosed by single quotes |
| int |
-32768 to 32767 |
Integer (ordinal). Whole numbers (no fractions, decimals). |
| long int |
-2147483648 to 2147483647 |
Long Integer. Same as long. |
| float |
-3.4E38 to 3.4E+38 |
Floating-Point (real). Decimal (base 10). Last digit is always approximate.
Used for simple calculations -accuaracy depends on computer; usually only looks at firsdt six digits and only about 300,000 return values possible. |
| double |
-1.7E308 to 1.7E+308 |
Double Floating-Point |
| long double |
-3.4E4932 to 1.1E+4932 |
Long Double Floating-Point |
Operators in Precedence Level
| Level |
Operator |
Description |
| 1 |
[ ] ( ) |
array index function call |
| 2 |
+ + -- + - ! ( ) |
increment decrement unary plus unary minus logical NOT type cast |
| 3 |
* / % |
multiply divide modulo |
| 4 |
+ - |
addition subtraction |
| 5 |
< < > > |
shift left (overloaded insertion) shift right (overloasded extraction) |
| 6 |
< > < = > = |
less than greater than less than or equal greater than or equal |
| 7 |
= = ! = |
equal not equal |
| 8 |
& & |
logical AND |
| 9 |
| | |
logical OR |
| 10 |
? : |
arithmetic IF |
| 11 |
= |
assignment (includes all assignment operators) |
| 12 |
, |
comma operator |
|