COSC-051 Lecture 6: Lecture 6

89 views2 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers