--to use a variable in a program, it must be defined by giving it a type and identifier
eg: double RadiusOnce defined the variable must be given a value
Using Named Constants
-defined in a statement and begins with the word "const"
--this is used to define a constant: in math Pi is a constant value (3.14159)...to represent this in C++, you do the following: const double PI = 3.14 ; --a constant is used to represent a value that does not change during the execution of a programChoosing Identifiers
Rules for choosing identifiers:Built in Data Types
1. double2. int and long
3. char:
Example: char Ch:
Ch = 'A';
cout<<Ch<<endl;
displays : AVARIABLE DEFINITIONS
VARIABLES can be defined in single statements or in multiple variables in one line
example: int x,y,zChar ch1,ch2
Expressions and Operators
-built in arithmetic operations include: (*) multiplication,
(+) addition, (-) subtraction, and ( / ) division
Promotion: numeric values of various types can be mixed in an expression: an expression involving two doubles, results in a double, however, whenever an integer and a double are used, C++ promotes the value with the narrow range to the value with the wider range: integer becomes a double: this avoids the problem known in Pascal as "type mismatch"
Integer Division: if you divide two integers, the resulting number will be truncated, or the decimals will be cut off!
Type Casting: when real division is done, type casting converts one of the values into a real number
Modulus Division: represented by %, Modulus division returns the remainder....similar to MOD in Pascal
Operator Precedence: same as order of operations in mathematics
Output Formatting