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

Char Item (Int Quantity (Float Price (Char Pass (Void Password

This C program implements an inventory management system with functions for entering a product, changing inventory quantities, making sales, generating an inventory report, and validating a password on login. The main function contains a menu loop that calls the appropriate function based on the user's choice. Product and inventory data is stored in arrays that are passed between functions to add, modify, or view the inventory records.

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)
29 views

Char Item (Int Quantity (Float Price (Char Pass (Void Password

This C program implements an inventory management system with functions for entering a product, changing inventory quantities, making sales, generating an inventory report, and validating a password on login. The main function contains a menu loop that calls the appropriate function based on the user's choice. Product and inventory data is stored in arrays that are passed between functions to add, modify, or view the inventory records.

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<string.h>
#include<conio.h>
#include<stdlib.h>
char item[100][20];
int quantity[100];
float price[100];
char pass[20]="Rong-1234";
void password()
{
char temp[20];
int f1,f2,f3,f4;
int i,len;
while(1)
{
system("cls");
f1=0;
f2=0;
f3=0;
f4=0;
printf("Enter Password: ");
scanf("%s",temp);
len=strlen(temp);
if(len<8)
{
printf("\nInvalid Password...\n");
printf("\npress any key to continue");
getch();
}
else
{
for(i=0; i<len; i++)
{
if(temp[i]>=65&&temp[i]<=91)
f1=1;//for upper case check.
else if(temp[i]>=97&&temp[i<=122])
f2=1;//for lower case check.
else if(temp[i]>=48&&temp[i]<=57)
f3=1;//for number check.
else
f4=1;//for special character check;
}
if(f1==1&&f2==1&&f3==1&&f4==1)
{
if(strcmp(temp,pass)==0)
{
printf("\nCorrect password\n");
break;
}
}
else
{
printf("\nInvalid Password...\n");
printf("\npress any key to continue");
getch();

}
printf("\nPress any key to go to the menu");
getch();

}
void enter_pro()
{
int i,flag=0;
//int flag=0;
char temp[20];
printf("\nEnter product name: ");
scanf("%s",temp);
for(i=0; i<100; i++)
{
if(strcmp(item[i],temp)==0)
{
printf("\nProduct already exist");
flag=1;
break;
}
}
if(flag==0)
{
for(i=0; i<100; i++)
{
if(item[i][0]=='\0')
{
strcpy(item[i],temp);
printf("\nEnter quantity: ");
scanf("%d",&quantity[i]);
printf("\nEnter unit price: ");
scanf("%f",&price[i]);
break;
}
}
}
printf("\n\nPress any key to continue");
getch();
}
void change_inven()
{
int i;
int flag=0;
char temp[20];
printf("\nEter product name: ");
scanf("%s",temp);
for(i=0; i<100; i++)
{
if(strcmp(item[i],temp)==0)
{
printf("\nEnter new quantity: ");
scanf("%d",&quantity[i]);
flag=1;
break;
}
}

if(flag==0)
{
printf("\nProduct does not exist");
}
printf("\n\nPress any key to continue");
getch();
}
void inven_report()
{
int i;
for(i=0; item[i][0]!='\0'; i++)
{
printf("\n%s",item[i]);
printf("\t%f",price[i]);
printf("\t%d\n",quantity[i]);
}
printf("\n\nPress any key to continue");
getch();
}
void sale()
{
int i,temp1;
int flag=0;
char temp[20];
printf("\nEnter product name: ");
scanf("%s",temp);
for(i=0; i<100; i++)
{
if(strcmp(item[i],temp)==0)
{
printf("\nEnter number of sold product: ");
scanf("%d",&temp1);
if(temp1<=quantity[i])
{
quantity[i]=quantity[i]-temp1;
}
else
{
printf("\nThis quantity not available");
}
flag=1;
break;
}
}
if(flag==0)
{
printf("\nProduct does not exist");
}
printf("\n\nPress any key to continue");
getch();
}
int menu()
{
int choice;
printf("\n\t\t\t1. Enter a product\n");
printf("\n\t\t\t2. Change inventory\n");
printf("\n\t\t\t3. Make sale\n");

printf("\n\t\t\t4. Inventory report\n");


printf("\n\t\t\t5. Exit\n");
printf("\n\nEnter a choice: ");
scanf("%d",&choice);
return choice;

}
int main()
{
password();
int choice;
while(1)
{
system("cls");
choice=menu();
if(choice==1)
{
enter_pro();
}
else if(choice==2)
{
change_inven();
}
else if(choice==3)
{
sale();
}
else if(choice==4)
{
inven_report();
}
else break;
}
return 0;
}

You might also like