COSC-051 Lecture Notes - Lecture 7: Fruit Snack, Semicolon, Infinite Loop

85 views3 pages

Document Summary

Use user input as intexpression in switch statement. Use menu choices as exp values to test against in the case statements. Ex: switch (gender) break; break; case f" : cout << female ; case m": cout << male ; default: cout << invalid gender ; A data type created by the programmer. Contains a set of named integer constants. Format: enum name {val1, val2, , van}; Examples: enum fruit {apple, grape, orange}; enum days {mon, tue, wed, thur, fri}; To define variables, use the enumerated data type name. A variable may contain any valid value for the data type snack = orange; if (workday == wed) // none here. Enum data type values are associated with integers, starting at 0 enum fruit {apple, grape, orange}; Enumerated data type values can be compared using their integer values if (snack ==1) Enumerated data type values cannot be assigned using their integer values snack = 2; // won"t work".

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

Related Documents