Practice Projects

๐Ÿง  C Mini Projects for Practice โ€” Dynamic Memory, Structs, Enums & File I/O #

These projects are designed to test and reinforce your understanding of:

  • Dynamic Memory Allocation (malloc, calloc, realloc, free)
  • Structs and Enums
  • Pointers and Arrays
  • File I/O (fopen, fprintf, fscanf, etc.)
  • Modular Design and Debugging

Each project can typically be completed in 1โ€“2 weeks with good testing and documentation.

More projects available here:
https://github.com/cpro-iiit/snake-project-starter.
https://cs50.harvard.edu/x/2023/labs/4/smiley/.
https://cs50.harvard.edu/x/2023/labs/4/volume/.
https://cs50.harvard.edu/x/2023/labs/5/.
https://cs50.harvard.edu/x/2023/labs/2/.

Reading/understanding these code and adding to it, will give you the confidence for large scale coding.


๐Ÿš€ Project 1: Student Record Management System #

Description #

Build a program to manage student records (name, roll number, marks, grade, etc.). Support dynamic addition/deletion of students, sorting by marks, and saving/loading from file.

Key Concepts #

  • Dynamic arrays of structs
  • File I/O (save/load)
  • Struct assignment and deep copies

Example Features #

  • Add/Delete/Update students
  • Calculate class average
  • Write to records.txt

๐Ÿงพ Project 2: Inventory Tracker for a Store #

Description #

Implement a simple inventory system that tracks items, quantities, and prices.

Key Concepts #

  • Structs for product info
  • File persistence
  • Enum for category (ELECTRONICS, FOOD, CLOTHING)

Features #

  • Add/Remove items
  • Search by name
  • Generate invoice file

๐Ÿงฉ Project 3: Library Management System #

Description #

Manage a small digital library database.

Key Concepts #

  • Linked list of books (dynamic allocation)
  • Struct with nested structs (Book, Author)
  • File I/O to store data between runs

Features #

  • Add/Remove/Search books
  • Issue/Return functionality
  • Save state to library.dat

๐Ÿงฎ Project 4: Matrix Operations Toolkit #

Description #

Write a program to handle matrix operations (addition, multiplication, transpose, determinant).

Key Concepts #

  • 2D dynamic arrays (pointer to pointer)
  • Functions that allocate and free matrices
  • Error checking for dimensions

Bonus #

  • Include file-based input/output for matrices.

๐Ÿง  Project 5: Quiz Game with Leaderboard #

Description #

A text-based quiz game that reads questions from a file, accepts answers, and maintains a leaderboard.

Key Concepts #

  • File I/O for question bank and leaderboard
  • Struct for player data
  • Enum for difficulty level

Features #

  • Add questions via file
  • Randomize question order
  • Save top 5 scores

๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘ Project 6 โ€” Mini Social Network #

๐ŸŽฏ Goal #

Simulate a simple social network using structs, pointers, and dynamic memory.

๐Ÿงฉ Key Concepts #

  • Dynamic memory (malloc, realloc, free)
  • Structs with pointer fields
  • Recursion for โ€œfriends-of-friendsโ€
  • File persistence
  • Bidirectional relationships

๐Ÿ—‚๏ธ Example Structures #

typedef struct Person {
    char name[30];
    struct Person** friends;
    int num_friends;
} Person;

๐Ÿงพ Features #

  1. Add new people
  2. Add friendships (bi-directional links)
  3. Print network connections
  4. Save / load network from file

๐Ÿ’ก Example Run #

Enter name: Alice
Enter name: Bob
Make friends? (Alice, Bob): y
Friendship created!
Aliceโ€™s friends: Bob
Bobโ€™s friends: Alice

๐Ÿช Project 7 โ€” Store Receipt Management System #

๐ŸŽฏ Goal #

Create a store checkout and receipt generator that stores items, computes totals, and saves transactions.

๐Ÿงฉ Key Concepts #

  • Structs for product, cart item, and receipt
  • Enums for product category
  • Dynamic arrays for cart items
  • File I/O for saving receipts

๐Ÿ—‚๏ธ Example Structures #

typedef enum {
    GROCERY,
    ELECTRONICS,
    CLOTHING
} Category;

typedef struct {
    int id;
    char name[50];
    float price;
    Category type;
} Product;

typedef struct {
    Product *product;
    int quantity;
} CartItem;

typedef struct {
    int receipt_id;
    CartItem *items;
    int item_count;
    float total;
} Receipt;

๐Ÿ’ป Features #

  1. Add products
  2. Display catalog
  3. Add to cart dynamically
  4. Generate and print receipts
  5. Save receipts to file

๐Ÿ’พ Example Output #

===== STORE MENU =====
1. Add product
2. Purchase
3. Print receipt
4. Exit

Product: Milk
Qty: 2
Total: 91.00
Receipt saved to receipts.txt

๐Ÿง Project 8 โ€” ATM Transaction System #

๐ŸŽฏ Goal #

Simulate an ATM machine where users can create accounts, deposit, withdraw, and view transaction history.

๐Ÿงฉ Key Concepts #

  • Structs and enums
  • Dynamic transaction list
  • File I/O for persistence
  • Secure PIN check

๐Ÿ—‚๏ธ Example Structures #

typedef enum {
    DEPOSIT,
    WITHDRAWAL,
    BALANCE_CHECK
} TransactionType;

typedef struct {
    TransactionType type;
    float amount;
    char timestamp[30];
} Transaction;

typedef struct {
    int account_number;
    char name[50];
    int pin;
    float balance;
    Transaction* history;
    int transaction_count;
} Account;

๐Ÿ’ป Features #

  1. Create account
  2. Login with PIN
  3. Deposit / Withdraw
  4. Show balance and transactions
  5. Save all data to file

๐Ÿงพ Example Output #

=== ATM SYSTEM ===
1. Create Account
2. Login
3. Exit

Account created: Alice (Acc #1001)
Deposit 500 โ†’ Balance = 500.00
Withdraw 100 โ†’ Balance = 400.00

๐Ÿ—‚๏ธ Submission & Documentation Checklist #

1. Cover Page #

Include title, student details, course name, instructor name, and date.

2. Project Report (3โ€“5 pages) #

  • Introduction
  • Design and Approach
  • Implementation Details
  • Testing and Results
  • Conclusion and Future Work

3. Source Code Folder #

  • .c files and a Makefile
  • Use header files for modularity
  • Compile with gcc -Wall -Wextra

4. README File #

  • Compilation and execution instructions
  • Input/output format description
  • Example runs

5. Example Input/Output Files #

Include at least 3 test cases:

  • Small, medium, and edge-case dataset.

6. Evaluation Rubric #

CriteriaDescriptionMarks
CorrectnessProgram compiles and meets requirements30
Memory HandlingProper use of malloc/free, no leaks15
Structs/EnumsModular and clean design15
File I/ORobust input/output10
Code QualityComments, naming, readability10
Testing & DocumentationExamples, explanations20
Total100

๐Ÿ’ก Tip: Always run your code through Valgrind to check for memory leaks before submission!