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

Write a statement that calls a function named IncreaseItemQty, passing the varia

ID: 3723402 • Letter: W

Question

Write a statement that calls a function named IncreaseItemQty, passing the variable addStock. Assign notebookInfo with the value returned by IncreaseItemQty.

#include <stdio.h>
#include <string.h>

typedef struct ProductInfo_struct {
   char itemName[30];
   int itemQty;
} ProductInfo;

ProductInfo IncreaseItemQty (ProductInfo productToStock, int increaseValue) {
   productToStock.itemQty = productToStock.itemQty + increaseValue;

   return productToStock;
}

int main(void) {
   ProductInfo notebookInfo;
   int addStock = 10;

   scanf("%s", notebookInfo.itemName);
   scanf("%d", &notebookInfo.itemQty);

   /* Your solution goes here */

   printf("Name: %s, stock: %d ", notebookInfo.itemName, notebookInfo.itemQty);

   return 0;
}

Explanation / Answer

#include <stdio.h>
#include <string.h>

typedef struct ProductInfo_struct {
char itemName[30];
int itemQty;
} ProductInfo;

ProductInfo IncreaseItemQty (ProductInfo productToStock, int increaseValue) {
productToStock.itemQty = productToStock.itemQty + increaseValue;

return productToStock;
}

int main(void) {
ProductInfo notebookInfo;
int addStock = 10;

scanf("%s", notebookInfo.itemName);
scanf("%d", &notebookInfo.itemQty);

/* Your solution goes here */
notebookInfo=IncreaseItemQty(notebookInfo, addStock);
printf("Name: %s, stock: %d ", notebookInfo.itemName, notebookInfo.itemQty);

return 0;
}

Output:

Name: aaaaaaaaaa, stock: 15

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