0% found this document useful (0 votes)
65 views4 pages

Struct Item - Info: #Include #Include #Include #Include #Include

This C program manages an inventory system for a shop. It defines data structures to store product information and includes functions for adding/modifying inventory, making sales, and generating reports. The main function loads data from a file, handles user login, and calls other functions based on the user's menu selection. Key functions include entry() to add new products, change() to modify quantities, sale() to process sales, and report() to view the current inventory and total value. All data is stored in memory and written back to a file upon changes.

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)
65 views4 pages

Struct Item - Info: #Include #Include #Include #Include #Include

This C program manages an inventory system for a shop. It defines data structures to store product information and includes functions for adding/modifying inventory, making sales, and generating reports. The main function loads data from a file, handles user login, and calls other functions based on the user's menu selection. Key functions include entry() to add new products, change() to modify quantities, sale() to process sales, and report() to view the current inventory and total value. All data is stored in memory and written back to a file upon changes.

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/ 4

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

h> struct item_info { char nm[100]; int qty,prc; }item[200]; int m; void entry(void); void change(void); void sale(void); void report(void); int login(void); void Select(void); void file(void); int main(void) { FILE *q=fopen("m.txt","r"); while(!feof(q)) { fflush(stdin); fgets(item[m].nm,100,q); strlwr(item[m].nm); fscanf(q,"%d",&item[m].qty); fscanf(q,"%d",&item[m++].prc); } fclose(q); system("cls"); printf("\n\n\t\tRAJIBUL'S SHOP\n\n\n"); if(login()) { printf("\n\n\t\tLOG IN ERROR\n\n\t\tTry Again\n\n\t\tpress any key to continue . . ."); getch(); main(); } Select(); return 0; } int login() { char pass[]="rajib",c[20]; printf("\n\n\t\tPassword: "); fflush(stdin); gets(c); if((!strcmp(pass,c)))return 0; else return 1; } void Select() { char input; system("cls"); printf("\n\n\t\t1. Enter a porduct\n\t\t2. Change the inventory\n\t\t3. Make sale\n\t\t4. Inventory report\n\t\t0.

Exit\n\n\t\tenter your choice\n"); input=getch(); if(input=='1')entry(); else if(input=='2')change(); else if(input=='3')sale(); else if(input=='4')report(); else if(input=='0')exit(0); else printf("\n\n\t\tInvalid selection !!! \n\t\tpress the correct key . . . . "); Sleep(500); Select(); } void entry(void) { int a; char s[100]; system("cls"); printf("\n\n\n\t\tEnter the name of the product: "); fflush(stdin); gets(s); strcat(s,"\n"); for(a=0 ; (a<m) ; a++)if((strcmp(s,item[a].nm))==0)break; if(a==m) { printf("\n\n\t\tprice: "); scanf("%d",&item[m].prc); strcpy(item[m].nm,s); printf("\n\n\t\tquantity: "); scanf("%d",&item[m++].qty); printf("\n\n\t\tThe product is successfully added to the inventory."); } else printf("\n\n\t\tThe product you entered already exists . . . "); printf("\n\t\tpress any key to continue . . . ."); file(); getch(); Select(); } void change(void) { int a; char s[100]; system("cls"); while(login()) { printf("\n\n\t\tLog in error . . . . \n\n\t\tpress enter to go to main menu . . . .\n\n\t\tor press any other key to log in"); if(getch()==13)Select(); else change(); } system("cls"); printf("\n\n\n\t\tEnter the name of the product: "); fflush(stdin); gets(s); strcat(s,"\n"); for(a=0 ; (a<m) ; a++)if((strcmp(s,item[a].nm))==0)break;

if(a==m) { printf("\n\n\t\tYour product doesn't exist . . \n\n\t\tpress any key to go to main menu . . .\n\n\tor press enter to give the correct product nm . . . ."); if(getch()==13)change(); Select(); } printf("\n\n\t\tThe present qty: %d",item[a].qty); printf("\n\n\t\tEnter the new quantity: "); scanf("%d",&item[a].qty); file(); printf("\n\n\t\tThe inventory has been upgraded. \n\n\t\tpress any key to continue . . . ."); getch(); Select(); } void sale() { int a,b,c; char s[100]; system("cls"); printf("\n\n\n\t\tEnter the name of product: "); fflush(stdin); gets(s); strcat(s,"\n"); for(a=0 ; (a<m) ; a++)if((strcmp(s,item[a].nm))==0)break; if(a==m) { printf("\n\n\n\t\tYour product doesn't exists . . . . \n\n\t\tpress any key to enter the correct product nm . . . . \n\n\t\tor press enter to go to main menu . . . . "); if(getch()==13)Select(); else sale(); } printf("\n\n\t\tEnter the quantity: "); scanf("%d",&a); for(b=0 ; (b<m) ; b++)if((strcmp(s,item[b].nm))==0)break; if(item[b].qty<a) { printf("\n\n\t\tThis much quantity is not available in the inventory . . . .\n\n\t\tpress enter to go to main menu . . . .\n\n\t\tpress any other key to sale again . . . ."); if(getch()==13)Select(); sale(); } item[b].qty-=a; printf("\n\n\t\tBill: %d\n\n\t\tqty left in the inventory: %d\n\n\t\tpress any key to go to main menu . . . ",item[b].prc*a,item[b].qty); file(); getch(); Select(); } void report() { int a,b=0;

char s[100]; system("cls"); while(login()) { printf("\n\n\t\tLog in error . . . . \n\n\t\tpress enter to go to main menu . . . .\n\n\t\tor press any other key to log in"); if(getch()==13)Select(); else report(); } system("cls"); printf("\n\n\t\tInventory Report\n\n "); for(a=0;a<m;a++) { b+=item[a].prc*item[a].qty; printf("\n\tproduct name: %s\n\tUnit price: %d\n\tAvailable quantity: %d\n",item[a].nm,item[a].prc,item[a].qty); } printf("\n\n\t\tTotal worth of the inventory: %d\n\n\t\tpress any key to go to main menu . . . ",b); getch(); Select(); } void file() { FILE *p=fopen("m.txt","w"); int a,b; for(a=0; a<m; a++) fprintf(p,"%s%d\n%d",item[a].nm,item[a].qty,item[a].prc); fclose(p); }

You might also like