Chapter 8: Problem 5
include
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.
Chapter 8: Problem 5
include
These are the key concepts you need to understand to accurately answer the question.
All the tools & learning materials you need for study success - in one app.
Get started for freeinclude
Given:
enum cropType \(\\{\text { WHEAT, CORN, RYE, BARLEY, OATS }\\}\) CropType crop;
circle the correct answer.
a. static cast \(\langle\text { int }\rangle\) (WHEAT) is 0
(i) true
(ii) false
b. static cast
Write \(\mathrm{C}++\) statements that do the following: a. Define an enum type, bookType, with the values MATH, CSC, ENGLISH, HISTORY, PHYSICS, and PHILOSOPHY. b. Declare a variable book of type bookType. c. Assign MATH to the variable book. d. Advance book to the next value in the list. e. Output the value of the variable book.
Consider the following \(\mathrm{C}++\) code: string str1; string str2; char ch; cin \(>>\operatorname{str} 1\) \(\operatorname{str} 2=\operatorname{str} 1\) cin \(>>\mathrm{ch}\) \(\operatorname{str} 2[0]=\mathrm{ch}\) cout \(<<\operatorname{str} 1<\cdots \rightarrow \cdots<<\operatorname{str} 2<<\) end 1 Answer the following questions. a. What is the output if the input is Hello J? b. What is the output if the input is Bingo \(\mathrm{R}\) ? c. What is the output if the input is Sunny B?
Mark the following statements as true or false. a. The following is a valid \(\mathrm{C}++\) enumeration type: enum romanNumerals \(\\{I, V, X, L, C, D, M\\}\) b. Given the declaration: enum cars \(\\{\mathrm{FORD}, \mathrm{GM}, \text { TOYOTA, } \mathrm{HONDA}\\}\) cars domesticcars \(=\mathrm{FORD}\) the statement: domesticcars \(=\) domesticcars +1 sets the value of domesticcars to GM. c. \(A\) function can return a value of an enumeration type. d. You can input the value of an enumeration type directly from a standard input device. e. The only arithmetic operations allowed on the enumeration type are increment and decrement. The values in the domain of an enumeration type are called enumerators. g. The following are legal \(C++\) statements in the same block of a \(C++\) program: enum mathStudent \(\\{\mathrm{BILL}, \text { JOHN, LISA, RON, CINDY, SHELLY }\\}\) enum historyStudent \(\\{\mathrm{AMANDA}, \mathrm{BOB}, \mathrm{JACK}, \mathrm{TOM}, \mathrm{SUSAN}\\}\) h. The following statement creates an anonymous type: enum \(\\{\mathrm{A}, \mathrm{B}, \mathrm{C}, \mathrm{D}, \mathrm{F}\\}\) studentGrade i. You can use the namespace mechanism with header files with the extension h. j. Suppose str \(=" \mathrm{ABCD}^{\prime \prime} ;\) After the statement \(\operatorname{str}[1]=^{\prime} a^{\prime} ;\), the value of str is "aBCD". k. Suppose str = "abcd". After the statement: \(\operatorname{str}=\operatorname{str}+\) "ABCD" the value of str is "ABCD".
What do you think about this solution?
We value your feedback to improve our textbook solutions.