Skip to content

Instantly share code, notes, and snippets.

@rohan-cce
Last active December 26, 2024 08:08
Show Gist options
  • Save rohan-cce/9dbaae9d27fb142458bf4dd2db76ebcf to your computer and use it in GitHub Desktop.
Save rohan-cce/9dbaae9d27fb142458bf4dd2db76ebcf to your computer and use it in GitHub Desktop.

Revisions

  1. rohan-cce revised this gist Dec 26, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,7 @@ void addItem(){
    scanf("%d",&newItem.id);
    getchar();
    printf("Enter name \n");
    fgets(newItem.name, sizeof(50), stdin);
    fgets(newItem.name, sizeof(newItem.name), stdin);
    printf("enter quantity \n");
    scanf("%d",&newItem.quantity);
    printf("enter price \n");
  2. rohan-cce revised this gist Dec 26, 2024. 1 changed file with 37 additions and 3 deletions.
    40 changes: 37 additions & 3 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -23,9 +23,43 @@ typedef struct{
    Item inventory[MAX_ITEMS];
    int itemCount = 0;


    // adding items to the warehouse
    void addItem(){
    Item newItem;
    printf("add items block\n");
    printf("Enter id\n");
    scanf("%d",&newItem.id);
    getchar();
    printf("Enter name \n");
    fgets(newItem.name, sizeof(50), stdin);
    printf("enter quantity \n");
    scanf("%d",&newItem.quantity);
    printf("enter price \n");
    scanf("%f", &newItem.price);

    inventory[itemCount] = newItem;
    itemCount++;

    printf("operation successfull !");


    // arr[index] = value

    // arr[0] = 1st product
    // arr[1] = 2nd product
    // arr[2] = 3rd product

    }


    void displayItems(){
    for(int i=0; i<itemCount; i++){
    printf("id is %d\n ",inventory[i].id);
    printf("name is %s\n ",inventory[i].name);
    printf("quantity is %d\n ",inventory[i].quantity);
    printf("price is %f\n ",inventory[i].price);

    }
    }


    @@ -48,10 +82,10 @@ int main(){

    switch(choice){
    case 1:
    printf("1 input \n ");
    addItem();
    break;
    case 2:
    printf("2 input \n");
    displayItems();
    break;
    case 3:
    printf("3 input \n");
  3. rohan-cce created this gist Dec 26, 2024.
    77 changes: 77 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,77 @@
    // inventory management system -> console based application
    #include<stdio.h>

    // new product

    // int -> id
    // string/ char arr -> name
    // int-> quantity
    // float -> price

    // structure

    #define MAX_ITEMS 100

    typedef struct{
    int id;
    char name[50];
    int quantity;
    float price;
    }Item;


    Item inventory[MAX_ITEMS];
    int itemCount = 0;


    void addItem(){

    }



    int main(){

    int choice;
    do{
    printf("\n\n\n Welcome to inventory management system\n");
    printf("1. add an item\n");
    printf("2. display all the items\n");
    printf("3. search an item\n");
    printf("4. delete an item\n");
    printf("5. update an item\n");
    printf("6. calculate the inventory value\n");
    printf("7. exit the application");

    printf("just input!\n");
    scanf("%d",&choice);

    switch(choice){
    case 1:
    printf("1 input \n ");
    break;
    case 2:
    printf("2 input \n");
    break;
    case 3:
    printf("3 input \n");
    break;
    case 4:
    printf("4 input \n");
    break;
    case 5:
    printf("5 input \n");
    break;
    case 6:
    printf("6 input \n");
    break;
    case 7:
    printf(" exiting :) \n");
    break;
    default:
    printf("sorry we dont support thhis option");
    }

    }while(choice !=7);
    }