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
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.
20. Assume the definition from the previous exercise:
a. Write C++ code that initializes each component of inventory as follows: partName to "?", partNum to 0, price to -1.0, and quantitiesInStock to 0.
b. Write C++ code that uses a loop to output the members of each element of inventory, with each member separated by a space character and each partType on its own line. Assume that the variable length indicates the number of elements in inventory which might be much less than 100.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started