Assignment Option1
Assignment Option1
Assignment
Objectives:
- Gain experience in managing structured data using binary files in C.
- Implement a modular and menu-driven program to handle CRUD (Create, Read,
Update, Delete) operations for product data.
- Use struct to represent product information, including product_id, product_name,
price, and quantity.
- Demonstrate reading, writing, and updating data in a binary file efficiently.
- Enhance problem-solving skills by implementing practical applications of file I/O
operations.
Problem Description:
Create a product management system where product data, including:
Product ID (unique identifier for each product),
Product Name (name of the product),
Price (unit price of the product),
Quantity (available stock of the product),
is stored in a binary file. The system should allow users to perform the following
operations through a menu-driven interface:
1. Write new product data to the file (overwrite existing data).
2. Append additional product records to the file.
3. Read and display all product records.
4. Modify a specific product by searching with its Product ID.
The program will simulate a real-world inventory system and include robust error
handling for file operations.
Situation Description:
Inventory management is a critical component of retail and wholesale businesses.
This case study simulates such a system by managing product data using binary files,
ensuring efficient storage and retrieval. By incorporating real-world functionality,
this program teaches students how to:
Use binary files for persistent storage,
Work with structures to group related data fields,
Develop modular and reusable code,
Implement CRUD operations effectively.
Specific Requirements:
1. Product Structure:
Include the following fields:
o product_id (integer),
o product_name (character array with a maximum length of 50),
o price (float),
o quantity (integer).
2. Menu Options:
Write products to the file (overwrite existing records).
Append additional products to the file.
Read and display all product records.
Modify a product by its product_id.
3. File Management:
Data is stored in a binary file (products.bin).
Ensure robust error handling for file operations.
4. Modular Design:
Use separate functions for each operation.
5. Output Formatting:
Display product details in a tabular format when reading data.