C++ Program
main()
{
}
Parts of a program
Example: Calculating volume of a sphere.
What is data?
Declarations
Named constants
Variables
Variable Initialization
Basic mathematical operations (+, -, *, /, %)
Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)
Modulus (%)
Type of result will be that of the greater of the two numerical types.
Examples:
Precedence and Associativity
Unary operators (+, -)
Other operators (~, &, |, ^, <<, >>, &&, ||)
See appendix C for a list of all operators and their precedences
Type conversion
Math library
sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), sinh(x), cosh(x), tanh(x), exp(x), log(x), log10(x), pow(x,y), sqrt(x), ceil(x), floor(x)
Assignment Expressions
Shortcuts
++
--
+=, -=, *=, /=, %=
Notes