Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

18. Assume the declarations of the previous exercise. Write C++ statements that

ID: 2246389 • Letter: 1

Question

18. Assume the declarations of the previous exercise. Write C++ statements that do the following:

a. Store the following information in cs_course. Do not redeclare cs_course.

name: the string literal "Programming I" (hint: you cannot use ‘=’ to overwrite the previous value for the name member because c-strings are really character arrays and you cannot assign one array to another, so you must use a c-string function instead)

callNum : 40101

credits : 4

grade : 'A'

b. In the classList array initialize each id to 0.

c. Copy the first component of the array classList into cs_student.

d. Update the id of the last student in the array classList by adding 1000000 to its previous value.

19. Assume that you have the following definition of a struct:

  struct partType

  {

     string partName;

     int partNum;

     float price;

     int quantitiesInStock;

  };

Declare an array, inventory, of 100 components of type partType.

Explanation / Answer

18. Some data from previous question(s) missing

19. An array of structure can be declared in 2 ways. One uses static memory allocation, other by dynamic memory alloc

type 1:
partType arr[100]; //static memory allocation

OR

type 2:
partType *arr = new partType[100]; //dynamic memory allocation

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote