COSC-051 Lecture 6: Lecture 6
Document Summary
Ex: cout << static_cast(4. 2); // this displays 4. More examples: char ch = c"; cout << ch << is stored as . << static_cast(ch) gallons = static_cast(area/500); avg = static_cast(sum)/count; Occurs when assigning a value that is too large (overflow) or too close to zero (underflow) to be held in a variable. Variables whose content cannot be changed during program execution. Used for representing constant values with descriptive names. Ex: const double tax_rate= 0. 0775; const int num_states = 50; Applies an arithmetic operation to a variable and assigns the result as the new value of that variable. These are also called compound operators or arithmetic assignment operators. Ex: sum += amt; is short for sum = sum + amt; x += 5; means x = x + 5; x -= 5; means x = x - 5; x *= 5; means x = x * 5; We can control how output displays for numeric and string data.