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

QL RUBRIC-Interpretation, Representation, Communication 20. Assume that you have

ID: 3729528 • Letter: Q

Question

QL RUBRIC-Interpretation, Representation, Communication 20. Assume that you have the following definition of a struct: struct partsType string partName; int partNum; double price; int quantitiesInStock; )i .Write a C++ code to initialize each component of inventory as follows: partName to null . Write a C++ code that uses a loop to output the data stored in inventory. Assume that .Cite all sources and any extra information used. string, partNum to -1, price to 0.0, and quantitieslnStock to O. the variable length indicates the number of elements in inventory.

Explanation / Answer

1)

for(int i = 0; i < length; ++i) {
   inventory[i].partName = "";
   inventory[i].partNum = -1;
   inventory[i].price = 0.0;
   inventory[i].quantitiesInStock = 0;
}

2)
for(int i = 0; i < length; ++i) {
   cout << "Name: " << inventory[i].partName << ", Part number: " << inventory[i].partNum << ", Price: " << inventory[i].price << ", Quantity: " << inventory[i].quantitiesInStock << endl;
}

3)
NO help taken from any sources