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

#include<stdio.h> void addToInventory(); void displayInventory(); int main (void

ID: 3659835 • Letter: #

Question

#include<stdio.h>


void addToInventory();

void displayInventory();

int main (void)


{


int choice;

int quantity[100];

int total=0;

char name[100][20];

float price[100];

int counter;

FILE *inputfile;

inputfile=fopen("inventory.dat","w");


do {printf("Please select a choice ");

printf("1.Add to the Inventory ");

printf("2.Adjust Quantity of an Item ");

printf("3.Print Inventory "); //user can select a number

printf("4.Remove an Item from Inventory ");

printf("5.Quit ");

scanf("%d",&choice);

switch(choice){

case 1:

printf("****User chose to add to inventory**** ");

addToInventory(name,price,quantity,&total);

break;

case 2:

printf("****User chose to adjust the quantity of an item**** ");

break;

case 3:

displayInventory(name,price,quantity,total);

break;

case 4:

printf("****User chose to remove an item from inventory**** ");

break;

default:

printf("****User chose to quit**** ");

for(counter=0;counter<total;counter++){//for loop begins

fprintf(inputfile, "%s %4.2f %d ",name[counter],price[counter],quantity[counter]);

}

break;

}

}

while(choice!=5);

return 0;

}

void addToInventory(char name[100][20],float price[100],int quantity[100],int *total)

{

printf("****Name of the first item?**** ");

scanf("%s", name[*total]);


printf("****Quantity that is in stock?**** ");

scanf("%d", &quantity[*total]);


printf("****Price of the item?**** ");

scanf("%f", &price[*total]);

(*total)++;

}


void displayInventory(char name[100][20],float price[100],int quantity[100],int total)

{

int counter;


for(counter=0;counter<total;counter++){

printf("%s %4.2f %d ",name[counter],price[counter],quantity[counter]);

}

}

Explanation / Answer

the programe is correct just run it