Question: Question 1 This quiz tests your ability to read (walk) through a piece of code and write out what is happening at each step in

Question 1

  1. This quiz tests your ability to read (walk) through a piece of code and write out what is happening at each step in the code. Select the answer set that best matches the step-by-step order of operation and output of the code, There are partial marks available if the answer you select is partially correct.

    Order the answers to show the correct order of operation of this code:

    #include #define SZ 3 struct OrderItem { int SKU; int quantityInStock; int reorderPoint; int reorderQuantity; }; struct OrderList { int SKU; int quantity; }; int main(void) { struct OrderItem items[SZ] = { {101, 5, 5, 6},{102, 3, 4, 5},{103, 7, 5, 7} }; struct OrderList orders[SZ] = { 0 }; int i; for (i = 0; i < SZ; i++) { if (items[i].quantityInStock <= items[i].reorderPoint) { orders[i].SKU = items[i].SKU; orders[i].quantity = items[i].reorderQuantity; printf("%d of %d added to order list. ", orders[i].quantity, orders[i].SKU); } else { orders[i].SKU = -1; printf("%d fully stocked. ", items[i].SKU); } } return 0; }

    give me the number of answer for each line below ?

i incremented by 1, i equals 3

7 <= 5? false enter else construct

orders[1].quantity set equal to items[1].reorderQuantity

program returns control to OS, exits with value 0

i incremented by 1, i equals 2

printf outputs to screen "5 of 102 added to order list"

3 < 3? false, exit for loop

orders[0].quantity set equal to items[0].reorderQuantity

orders[2].sku set to -1, printf outputs to screeen "103 fully stocked."

orders[1].SKU set to 102 ( items[1].SKU)

3 <= 4? true, enter if construct

i incremented by 1, i equals 1

1 < 3? true - proceed to first line in loop

orders[0].SKU set to 101 ( items[0].SKU)

printf outputs to screen "6 of 101 added to order list"

for loop is entered, i is set to 0, 0 < 3? true - proceed to first line in loop

OrderItem array items is intantiated with 3 elements

2 < 3? true - proceed to first line in loop

OrderList array orders is declared with 3 elements and set to a safe state

5 <= 5? true, enter if construct

int i is declared

items[0] receives 101,5 5,6 - items[1] receives 102,3,4,5 - items[2] receives 103,7,5,7

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!