Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Problem 1

Mark the following statements as true or false. a. The following is a valid C++ enumeration type: enum romanNumerals I,V,X,L,C,D,M b. Given the declaration: enum cars FORD,GM, TOYOTA, HONDA cars domesticcars =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 BILL, JOHN, LISA, RON, CINDY, SHELLY  enum historyStudent AMANDA,BOB,JACK,TOM,SUSAN h. The following statement creates an anonymous type: enum A,B,C,D,F studentGrade i. You can use the namespace mechanism with header files with the extension h. j. Suppose str ="ABCD; After the statement str[1]=a;, the value of str is "aBCD". k. Suppose str = "abcd". After the statement: str=str+ "ABCD" the value of str is "ABCD".

Problem 2

Write 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.

Problem 4

Given: enum cropType  WHEAT, CORN, RYE, BARLEY, OATS  CropType crop; circle the correct answer. a. static cast  int  (WHEAT) is 0 (i) true (ii) false b. static cast (static_cast\mathrm{WHEAT}\) (i) true (ii) false d. for (crop= wheat ;crop<= oats ;++crop) cout \(<

Problem 5

include / / Line 1 int main () / / Line 2 \{ cout << "Hello World! " << endl: / / Line 3 return 0 / / Line \} # What is wrong with the following program? #include / / Line 1 int main () / / Line 2 \{ cout << "Hello World! " << endl: / / Line 3 return 0 / / Line \}

Problem 8

include //Line 1 #include //Line 2 using std; / / Line 3 int main () / / Line 4 \{ return 0 / / Line 5 \} # What is wrong with the following program? #include //Line 1 #include //Line 2 using std; / / Line 3 int main () / / Line 4 \{ return 0 / / Line 5 \}

Problem 9

Consider the following C++ code: string str1; string str2; char ch; cin >>str1 str2=str1 cin >>ch str2[0]=ch cout <<str1<<<str2<< 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 R ? c. What is the output if the input is Sunny B?

Problem 12

Consider the following statement: string str = "Now is the time for the party!"; What is the output of the following statements? (Assume that all parts are independent of each other.) a. cout << str.size ()<< endl b. cout<<str.substr(7,8)<<end1 c. string: : size_type ind =str. find ( 'f ) string s=str. substr (ind+4,9) cout <<s<< endl d. cout << str.insert (11, "best ")<< endl e. str.erase (16,14) str.insert (16, "to study for the exam? "); cout << str << endl

Access millions of textbook solutions in one place

  • Access over 3 million high quality textbook solutions
  • Access our popular flashcard, quiz, mock-exam and notes features
  • Access our smart AI features to upgrade your learning
Get Vaia Premium now
Access millions of textbook solutions in one place

Recommended explanations on Computer Science Textbooks