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", ¬ebookInfo.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", ¬ebookInfo.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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.