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. All members of a struct must be of different types. b. \(A\) function cannot return a value of type struct. c. A member of a struct can be another struct. d. The only allowable operations on a struct are assignment and member selection. e. An array can be a member of a struct. f. In \(C++,\) some aggregate operations are allowed on a struct. g. Because a struct has a finite number of components, relational operations are allowed on a struct.

Problem 2

Define a struct, checkingAccount, to store the following data about a checking account: account holder's name (string), account number (int), balance (double), and the interest rate (double).

Problem 4

Define a struct, movieType, to store the following data about a movie: movie name (string), movie director (string), producer (string), the year movie was released (int), and number of copies in stock.

Problem 6

Consider the following statements: struct nameType struct dateType struct personalInfoType { { { string first; int month; nameType name; string last; int day; int pID; }; int year; dateType dob; }; }; personalInfoType person; personalInfoType classList[100]; nameType student; Mark the following statements as valid or invalid. If a statement is invalid, explain why. a. person.name.first = "William"; b. cout << person.name << endl; c. classList[1] = person; d. classList[20].pID = 000011100; e. person = classList[20]; f. student = person.name; g. cin >> student; h. for (int j = 0; j < 100; j++) classList[j].pID = 00000000; i. classList.dob.day = 1; j. student = name;

Problem 9

Assume that you have the following definition of a struct. struct partsType { string partName; int partNum; double price; int quantitiesInStock; }; Declare an array, inventory, of 100 components of type partsType.

Problem 12

Suppose that you have the following definitions: struct timeType struct tourType { { int hr; string cityName; double min; int distance; int sec; timeType travelTime; }; }; a. Declare the variable destination of type tourType. b. Write C++ statements to store the following data in destination: cityName—Chicago, distance—550 miles, travelTime—9 hours and 30 minutes. c. Write the definition of a function to output the data stored in a variable of type tourType. d. Write the definition of a value-returning function that inputs data into a variable of type tourType. e. Write the definition of void function with a reference parameter of type tourType to input data in a variable of type tourType.

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