Skip to content
Laviyx Learn

Try

Mini project

Bank Account Management System in C

A menu-driven C program that creates bank accounts, handles deposits, withdrawals and transfers with balance checks, keeps a transaction history, and stores records in a binary file.

Beginner 1–2 weeks 1 studentUpdated

CstructsFile handlingGCC

The problem

A bank needs to keep every customer's balance correct after each transaction and never lose records when the program stops. This is a popular first-year project because it uses most of the C basics together: structs, functions, loops, strings and files.

Features to build

  • Create an account with an automatically generated account number, name and opening balance
  • Deposit and withdraw money, rejecting negative amounts and withdrawals larger than the balance
  • Transfer money between two accounts
  • Show account details and a mini statement of the last transactions
  • Search an account by number and close an account
  • Save all accounts to a binary file and load them when the program starts

Suggested data model

C
struct Account {
    int number;
    char name[50];
    double balance;
    int active;      /* 1 = open, 0 = closed */
};

struct Transaction {
    int account;
    char type;       /* 'D' deposit, 'W' withdrawal, 'T' transfer */
    double amount;
    long timestamp;
};

Build plan

  1. 1

    Define the structs and the menu

    Write the Account struct and a do-while loop with a switch for each menu option.

  2. 2

    Create and find accounts

    Keep accounts in an array, generate the next account number from the highest used, and write a find function that returns the index or -1.

  3. 3

    Deposit, withdraw and transfer

    Write one function for each, with checks for invalid amounts and low balance. Pass the account by pointer so the function can change the balance.

  4. 4

    Save and load with binary files

    Use fopen with wb and rb, and fwrite and fread for the whole array. Check every fopen result for NULL.

  5. 5

    Input safety

    Check the return value of scanf, and read names with fgets so long names do not overflow the array.

  6. 6

    Test and document

    Test withdrawals of exactly the balance, transfers to the same account and closed accounts. Write a README with how to compile with gcc.

Learn these first

Each part of the project is taught in one of these free lessons.

Make it stand out

  • A 4-digit PIN for each account, checked before withdrawals
  • Monthly interest for savings accounts
  • Store transactions in their own file, with date and time from time.h
  • Split the program into several .c and .h files

Viva and interview questions

Try to answer each one aloud before you open it.

  • Why did you use a struct?

    An account has several related values: number, name and balance. A struct keeps them together as one variable, so I can store accounts in an array and pass one account to a function.

  • Why do you pass the account to deposit() as a pointer?

    C passes arguments by value. With a pointer, the function changes the original account's balance instead of a copy.

  • What is the difference between a text file and a binary file here?

    A binary file stores the struct's bytes exactly as they are in memory, so fwrite and fread save and load whole records quickly. A text file is human-readable but needs formatting and parsing.

  • How do you stop a user from withdrawing more than the balance?

    Before changing the balance, the withdraw function checks that the amount is positive and not greater than the balance. If not, it prints a message and returns without changing anything.

  • Why is double not ideal for money in real banks?

    Floating-point numbers cannot store many decimal values exactly, so small rounding errors can appear. Real systems store money as whole paise in an integer type, or use decimal types.

What to put in your project report

  1. Abstract: the problem, your solution and the result in one paragraph.
  2. Introduction and problem statement: who has the problem and why it matters.
  3. Requirements: the features (functional) and qualities such as speed and security (non-functional).
  4. Design: architecture diagram, database tables or data flow, and screen layouts.
  5. Implementation: the main modules and the most interesting code, explained.
  6. Testing: the test cases you ran, with inputs, expected and actual results.
  7. Results: screenshots or numbers that show the project working.
  8. Conclusion and future scope: what you achieved and what you would add next.

Your college may give its own format. Follow that first, and use this list to check nothing is missing.