afrinc
afrinc
h>
#include <string.h>
struct Product
int productID;
char productName[50];
int quantity;
float unitPrice;
};
int main() {
int productCount = 0;
int choice;
do
printf("6. Exit\n");
scanf("%d", &choice);
switch (choice) {
case 1:
addProduct(products, &productCount);
break;
case 2:
updateProduct(products, productCount);
break;
case 3:
displayProducts(products, productCount);
break;
case 4:
purchaseProduct(products, productCount);
break;
case 5:
checkAvailability(products, productCount);
break;
case 6:
break;
default:
}
} while (choice != 6);
return 0;
return;
scanf("%d", &newProduct.productID);
scanf("%s", newProduct.productName);
scanf("%d", &newProduct.quantity);
scanf("%f", &newProduct.unitPrice);
if (strcmp(products[i].productName, newProduct.productName) == 0) {
return;
products[*productCount] = newProduct;
(*productCount)++;
scanf("%d", &productID);
if (products[i].productID == productID) {
scanf("%d", &products[i].quantity);
scanf("%f", &products[i].unitPrice);
found = 1;
break;
if (!found) {
{
if (productCount == 0) {
return;
printf("-------------------------\n");
char productName[50];
int quantity;
scanf("%s", productName);
scanf("%d", &quantity);
if (strcmp(products[i].productName, productName) == 0) {
products[i].quantity -= quantity;
printf("Purchase successful. Total cost: %.2f\n", quantity * products[i].unitPrice);
} else {
return;
char productName[50];
scanf("%s", productName);
if (strcmp(products[i].productName, productName) == 0) {
return;