0% found this document useful (0 votes)
41 views

Struct Inventory (Char Product (Struct Inventory S (

This C program manages an inventory system with the following functionality: 1. Users can enter product information like name, quantity, and price to add to inventory. 2. Inventory can be changed by modifying product quantities. 3. Products can be sold by reducing quantities after a sale. 4. An inventory report prints total value of inventory by multiplying quantity by price for each product. 5. The program runs a password protected menu loop allowing selection of add, change, sale, report, or exit options.

Uploaded by

sohagiut
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Struct Inventory (Char Product (Struct Inventory S (

This C program manages an inventory system with the following functionality: 1. Users can enter product information like name, quantity, and price to add to inventory. 2. Inventory can be changed by modifying product quantities. 3. Products can be sold by reducing quantities after a sale. 4. An inventory report prints total value of inventory by multiplying quantity by price for each product. 5. The program runs a password protected menu loop allowing selection of add, change, sale, report, or exit options.

Uploaded by

sohagiut
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

h> struct inventory{ char product[100]; int quantity; double price;}; struct inventory s[100]; main() { int a,b,i,j,k,l,e; char c[100], d[100],password[100]; double total,sum; printf("Enter password: "); scanf("%s",password); if(!strcmp(password,"Fullstop.")) { for(;;) { system("cls"); printf("\n\n\t\t\t\tMain Menu\n\n\n1. Enter product(s)\n\n2. Change Inventory\n\n3. Make Sale(s)\n\n4. Inventory Report\n\n5. Exit\n\n\n"); printf("Your Option: "); scanf("%d",&a); if(a==1) {system("cls"); printf("Enter the Number of products you want to input: "); scanf("%d",&k); system("cls"); for(i=0; i<k; i++) {printf("Enter Name: "); scanf("%s",&s[i].product); printf("\nEnter Quantity: "); scanf("%d",&s[i].quantity); printf("\nEnter Price per unit: "); scanf("%lf",&s[i].price); printf("\n");} system("cls"); printf("Products are successfully Saved in the Inventory.\n\n\n\n\nPress Enter to go back to the Main Menu."); getch();} if(a==2) { for(;;) {system("cls"); printf("Enter the product name that you want to Change :\n"); scanf("%s",&c); printf("Enter the number of quantities you want to further add :\n"); scanf("%d",&b); for(i=0; i<6; i++) { if(!strcmp(c,s[i].product)) { s[i].quantity=s[i].quantity+b; printf("Product Name: %s\nQuantity %d\nPrice %.2lf\n\n",s[i].product,s[i].quantity,s[i].price); }}getch(); system("cls"); printf("If you want to alter any other products then\nPress '1' for Yes\nPress '2' for No\nYour choice: "); scanf("%d",&e); if(e==1) continue; else system("cls"); printf("Inventory Upgraded.\n\n\n\nPress Enter to go back to the Main Menu."); getch();

break;}} if(a==3) { for(;;) {system("cls"); printf("Enter the product name you want to sell: "); scanf("%s",&d); printf("Enter the number of quantites you want to sell: "); scanf("%d",&l); for(i=0; i<k; i++) { if(!strcmp(d,s[i].product)) {if((s[i].quantity-l)>=0) {s[i].quantity=s[i].quantity-l; system("cls"); printf("Product Name: %s\nQuantity: %d\n Price: %.2lf\n",s[i].product,s[i].quantity,s[i].price); getch();} else printf("\nQuantity sold cannot be more than quantity present"); getch(); }} system("cls"); printf("If you want to make sale again then\nPress '1' for Yes\nPress '2' for No\nYour choice: "); scanf("%d",&e); if(e==1) continue; else system("cls"); printf("Inventory Upgraded.\n\n\n\n\nPress Enter to go back to the Main Menu."); getch(); break;}} if(a==4) {system("cls"); for(i=0; i<k; i++) {sum=s[i].quantity*s[i].price; total = total + sum; printf("Product Name: %s\nQuantity: %d\nPrice Per Unit: %.2lf\n",s[i].product,s[i].quantity,s[i].price); } printf("Total Bill = %.2lf\n\n\n\n\nPress Enter to go back to the Main Menu.",total);} getch(); if(a==5) {system("cls"); printf("Press Enter to Shut Down."); exit(0);}}} else printf("\nWRONG PASSWORD\n"); exit (0); }

You might also like