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

printf ("%d/n",strlen (Password) ) : Int Password - Identify (Char STR ) (

- The document contains C code for a program that manages an inventory system for a store. - It allows the user to enter a password, add new items to the inventory, modify item quantities, view the total inventory and worth, and make sales. - Functions are defined for password validation, adding/modifying items, calculating totals, and processing sales. Arrays store item names, quantities, prices, sales data, and costs.

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

printf ("%d/n",strlen (Password) ) : Int Password - Identify (Char STR ) (

- The document contains C code for a program that manages an inventory system for a store. - It allows the user to enter a password, add new items to the inventory, modify item quantities, view the total inventory and worth, and make sales. - Functions are defined for password validation, adding/modifying items, calculating totals, and processing sales. Arrays store item names, quantities, prices, sales data, and costs.

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

#include<stdio.

h>
#include<string.h>
int password_identify(char str[]){
char s[100];
int n;
//printf("%d\n",strlen(password));
printf("Enter the password:");
scanf("%s",s);
//printf("%s",str);
if(strcmp(s,str)==0){
//printf("Right\n");
return 0;
}
else{
printf("wrong password boss!\n");
printf("Enter 1 to try again/2 to return main menu/exit this
option\n");
scanf("%d",&n);
if (n==1){
password_identify(str);
}
if(n==2){
return -1;
}
}
}
int main(){
int i,j,k,a,b,total,n,flag=0,p,l=3;
printf("<<WELCOME TO COMMANDER'S SHOP>>\n");
printf("===============================\n\nHello Boss!\n");
char item[100];
char name[100][100]={"rice","pulse","cake"};
int quantity[100];int price[100];int used[100];int cost[100];
for(i=0;i<l;i++){
quantity[i]=100,used[i]=0,cost[i]=0,price[i]=40;
}
char password[]="Dark457+";
printf("\ndefault password is %s\n",password);
if (password_identify(password)==-1){
printf("Its ok boss!, Try later");
}
else{
printf("\nLook up your present condition\n\n");
printf("NAME\tQUANTITY
PRICE");
printf("\n----\t------------\n\n");
for (i=0;i<l;i++){
printf("%s \t %d \t
%d\n",name[i],quantity[i],price[i]);
}
for(;;){
printf("\nPress 1 to enter a item\nPress2 to change an
item\nPress 3 make sell\nPress 4 to show total inventory\nPress 6 to
exit\n");
scanf("%d",&n);
if(n==6){printf("Thanx for using");break;}
if(n==1){
while(1==1){

flag=0;
printf("\nEnter the item name:");
scanf("%s",item);
for(i=0;i<l;i++){
if(strcmp(name[i],item)==0){
flag=1;
printf("The item is already in\n");
break;
}
}
if(flag==0){
strcpy(name[l],item);
used[l]=0,cost[l]=0;
printf("Enter the price of %s:",name[l]);
scanf("%d",&price[l]);
printf("Enter the quantity of %s:",name[l]);
scanf("%d",&quantity[l]);
l++;
}
printf("\nEnter 1 to enter a new item\nEnter 2 to
return main menu:");

scanf("%d",&p);
if(p==1){
continue;
}
if(p==2){
break;
}

}
}
if(n==2){
if (password_identify(password)==-1){
continue;
}
else{
while(1==1){
flag=0;
printf("\nEnter the item name u want to
change:");

scanf("%s",item);
for(i=0;i<l;i++){
if(strcmp(name[i],item)==0){
flag=1;
printf("The present quantity of %s is
%d\n\n",name[i],quantity[i]);
printf("Enter the new quantity:");
scanf("%d",&quantity[i]);
break;
}
}
if(flag==0){printf("the item is not in
list\n");}
printf("Enter 1 to enter a new item\nEnter 2 to
return main menu\n");
scanf("%d",&p);
if(p==1){continue;}
if(p==2){break;}

}
if(n==4){
if (password_identify(password)==-1){continue;}
total=0;
printf("\nNAME\tQUANTITY
PRICE");
printf("\n----\t------------\n\n");
for (i=0;i<l;i++){
printf("%s \t %d \t
%d\n",name[i],quantity[i],price[i]);
total=total+cost[i];
}
printf("\n\nThe toatal worth is %d\n",total);
printf("\nNAME\t WORTH\n");
printf("------\t -----\n");
for (i=0;i<l;i++){
printf("%s\t
%d
\n",name[i],cost[i]);
}
}
if(n==3){
while(1==1){
flag=0;
printf("Enter the item name u want to sell:");
scanf("%s",item);
for(i=0;i<l;i++){
if(strcmp(name[i],item)==0){
flag=1;
printf("The present quantity of %s is
%d\n",name[i],quantity[i]);
printf("Enter quantity u want to sell:");
scanf("%d",&p);
if(p>quantity[i]){printf("This amount is
not in ur store\n");}
else{
quantity[i]=quantity[i]-p;
cost[i]=cost[i]+p*price[i];
used[i]=used[i]+p;
}
break;
}
}
if(flag==0){printf("the item is not in list\n");}
printf("\nEnter 1 to sell a new item\nEnter 2 to
return main menu");
scanf("%d",&p);
if(p==1){continue;}
if(p==2){break;}
}
}
}
}
return 0;
}

You might also like