Fill This Form To Receive Instant Help
Homework answers / question archive / write out what is happening at each step in the code
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
#include<stdio.h>
#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.n", orders[i].quantity, orders[i].SKU);
}
else
{
orders[i].SKU = -1;
printf("%d fully stocked.n", items[i].SKU);
}
}
return 0;
}
1- i incremented by 1, i equals 3.
2- 7 <= 5? false enter else construct.
3- orders[1].quantity set equal to items[1].reorderQuantity.
4- program returns control to OS, exits with value 0.
5- i incremented by 1, i equals 2.
6- printf outputs to screen "5 of 102 added to order list".
7- 3 < 3? false, exit for loop.
8- orders[0].quantity set equal to items[0].reorderQuantity
9- orders[2].sku set to -1, printf outputs to screeen "103 fully stocked.".
10- orders[1].SKU set to 102? ?( items[1].SKU).
11- 3 <= 4? true, enter if construct
12- i incremented by 1, i equals 1
13- 1 < 3? true - proceed to first line in loop
14- orders[0].SKU set to 101 ??( items[0].SKU)
15- printf outputs to screen "6 of 101 added to order list"
16- for loop is entered, i is set to 0, 0 < 3? true - proceed to first line in loop
17- OrderItem array items is intantiated with 3 elements
18- 2 < 3? true - proceed to first line in loop
19- OrderList array orders is declared with 3 elements and set to a safe state
20- 5 <= 5? true, enter if construct?
21- int i is declared
22- items[0] receives 101,5 5,6 - items[1] receives 102,3,4,5 - items[2] receives 103,7,5,7