Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
🔴 Advanced  ·  Lesson 64

C++ Mini Projects for Students

In this lesson: 8 C++ mini project ideas plus a complete report card project with source code — great for practical files. In Hindi & English.

Why build a mini project?

Reading about loops, classes and files is one thing; combining them into a working program is where C++ finally makes sense. A mini project also gives you something to show — for the Class 12 practical exam, a BCA/B.Tech lab submission or an internship interview. This page lists eight projects in increasing difficulty, the concepts each uses, and then builds one complete project step by step.

8 project ideas

#ProjectKey featuresConcepts usedLevel
1Student report cardAdd students, enter 5 marks, total, percentage, grade, merit listclass, vector, sort, functionsBeginner
2Quiz gameQuestions from a file, score, timer, high scorefile handling, vector, randomBeginner
3Library managementAdd/search/issue/return books, fine for late returnclasses, file handling, searchIntermediate
4Bank account systemOpen account, deposit, withdraw, statement, PIN checkencapsulation, validation, filesIntermediate
5Tic-tac-toe2-player board, win/draw detection2D arrays, functions, loopsBeginner
6Inventory / shop billingProducts, stock, bill with GST, low-stock alertmap, iomanip, filesIntermediate
7Hotel room bookingRoom types, booking dates, availability, invoiceinheritance, vector, datesAdvanced
8Contact bookAdd/edit/delete/search contacts, sort by namemap or vector, strings, filesBeginner

How to plan any project

  1. Write the feature list — what the user can do (add, view, search, delete, save).
  2. Identify the data — what one record holds (roll, name, marks) → that becomes a class.
  3. Design the menu — a do … while loop with a switch on the user's choice.
  4. Build one feature at a time and test it before starting the next.
  5. Add file saving last, once everything works in memory.
  6. Handle bad input — letters instead of numbers, empty lists, duplicate roll numbers.

Complete project: Student Report Card

The project below is complete and compiles with any C++17 compiler. It stores students in a vector, calculates grades, prints a merit list and saves data to students.txt so records survive between runs.

C++
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <limits>

const int SUBJECTS = 5;
const std::string DATA_FILE = "students.txt";

class Student {
public:
    int roll = 0;
    std::string name;
    int marks[SUBJECTS] = {0};

    int total() const {
        int t = 0;
        for (int m : marks) t += m;
        return t;
    }
    double percentage() const { return total() * 100.0 / (SUBJECTS * 100); }
    char grade() const {
        double p = percentage();
        if (p >= 90) return 'A';
        if (p >= 75) return 'B';
        if (p >= 60) return 'C';
        if (p >= 33) return 'D';
        return 'F';
    }
};

int readInt(const std::string& prompt, int lo, int hi) {
    int x;
    while (true) {
        std::cout << prompt;
        if (std::cin >> x && x >= lo && x <= hi) return x;
        std::cout << "  Please enter a number from " << lo << " to " << hi << ".\n";
        std::cin.clear();
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    }
}

void save(const std::vector<Student>& list) {
    std::ofstream out(DATA_FILE);
    for (const auto& s : list) {
        out << s.roll << ' ' << s.name;
        for (int m : s.marks) out << ' ' << m;
        out << '\n';
    }
}

std::vector<Student> load() {
    std::vector<Student> list;
    std::ifstream in(DATA_FILE);
    Student s;
    while (in >> s.roll >> s.name) {
        for (int& m : s.marks) in >> m;
        list.push_back(s);
    }
    return list;
}

void addStudent(std::vector<Student>& list) {
    Student s;
    s.roll = readInt("Roll number: ", 1, 9999);
    for (const auto& x : list)
        if (x.roll == s.roll) { std::cout << "  Roll number already exists.\n"; return; }
    std::cout << "Name (one word): ";
    std::cin >> s.name;
    for (int i = 0; i < SUBJECTS; i++)
        s.marks[i] = readInt("  Marks in subject " + std::to_string(i + 1) + ": ", 0, 100);
    list.push_back(s);
    save(list);
    std::cout << "  Saved.\n";
}

void printTable(const std::vector<Student>& list) {
    if (list.empty()) { std::cout << "  No records yet.\n"; return; }
    std::cout << std::left << std::setw(6) << "Roll" << std::setw(12) << "Name"
              << std::right << std::setw(6) << "Total" << std::setw(8) << "%"
              << std::setw(7) << "Grade" << "\n";
    for (const auto& s : list) {
        std::cout << std::left << std::setw(6) << s.roll << std::setw(12) << s.name
                  << std::right << std::setw(6) << s.total()
                  << std::setw(8) << std::fixed << std::setprecision(1) << s.percentage()
                  << std::setw(7) << s.grade() << "\n";
    }
}

void meritList(std::vector<Student> list) {            // copy: keep original order
    std::sort(list.begin(), list.end(),
              [](const Student& a, const Student& b) { return a.total() > b.total(); });
    printTable(list);
}

void search(const std::vector<Student>& list) {
    int r = readInt("Roll to search: ", 1, 9999);
    auto it = std::find_if(list.begin(), list.end(),
                           [r](const Student& s) { return s.roll == r; });
    if (it == list.end()) { std::cout << "  Not found.\n"; return; }
    printTable({*it});
}

int main() {
    std::vector<Student> students = load();
    int choice;
    do {
        std::cout << "\n=== Report Card System (" << students.size() << " students) ===\n"
                  << "1. Add student\n2. Show all\n3. Merit list\n4. Search by roll\n0. Exit\n";
        choice = readInt("Choice: ", 0, 4);
        switch (choice) {
            case 1: addStudent(students); break;
            case 2: printTable(students); break;
            case 3: meritList(students);  break;
            case 4: search(students);     break;
        }
    } while (choice != 0);
    std::cout << "Goodbye!\n";
    return 0;
}
=== Report Card System (2 students) === 1. Add student 2. Show all 3. Merit list 4. Search by roll 0. Exit Choice: 3 Roll Name Total % Grade 2 Priya 462 92.4 A 1 Aman 389 77.8 B

How the project works

  • **Student class** keeps each record's data and calculates total(), percentage() and grade() — the calculation lives in one place.
  • **readInt()** validates every number and recovers if the user types letters (cin.clear() + cin.ignore()).
  • **vector<Student>** grows as students are added; no fixed array size.
  • **save() / load()** use ofstream / ifstream so data is kept in students.txt between runs.
  • Merit list copies the vector and sorts it with a lambda, leaving the original order untouched.
  • Menu is a do … while loop with switch, the standard structure for console projects.

Ideas to extend it

  • Store subject names and print a full report card for one student.
  • Allow names with spaces using std::getline.
  • Add edit and delete options.
  • Show class average, highest and lowest in each subject.
  • Split the code into student.h, student.cpp and main.cpp (see header files).

What to include in the project report

  1. Certificate and acknowledgement (school format)
  2. Aim and introduction
  3. Hardware and software requirements (e.g. Windows 10, Code::Blocks 20.03 with GCC)
  4. Description of classes and functions
  5. Menu flow / flowchart
  6. Complete source code
  7. Output screenshots for each menu option
  8. Limitations and future scope
  9. Bibliography (textbook, CodingEasily lessons you used)

Common mistakes in student projects

  • Using conio.h, clrscr(), gotoxy() or graphics.h from Turbo C++ — they do not compile on modern compilers.
  • No input validation — typing a letter sends the program into an infinite loop.
  • Global variables everywhere instead of a class.
  • Saving data only on exit — a crash loses everything; save after each change.
  • Copying a project without understanding it — the viva will expose it.
🏋️ Practice

Pick project 4 (bank account). Create an Account class with private balance, deposit() and withdraw() that refuse invalid amounts, a menu, and file saving. Then add a SavingsAccount class using inheritance that adds monthly interest.

Summary

  • Mini projects combine classes, vectors, functions, menus and files into one program.
  • Plan features → data → menu, then build and test one feature at a time.
  • Validate all input and save to a file after every change.
  • The report card project above is a complete, modern template you can extend.

Related: file handling, classes and objects, vector, C++ practice programs, C mini projects.

Frequently Asked Questions

What is a good C++ mini project for a Class 12 student?
A student report card system, library management system or bank account system are ideal. Each uses classes, arrays or vectors, functions, file handling and menus — exactly the topics in the CBSE Computer Science syllabus — and can be finished in one to two weeks.
Which concepts should a C++ mini project include?
A good project shows classes and objects, constructors, a menu using switch inside a loop, input validation, vector or arrays to store records, and file handling with fstream so data is saved between runs. Inheritance or operator overloading are a bonus.
How do I save data permanently in a C++ project?
Use file handling from <fstream>: write records with ofstream when the program exits or after each change, and read them back with ifstream when it starts. A simple text format with one record per line is easiest to debug.
What should I write in a C++ project report?
Include the title and aim, hardware and software used, a description of each class and function, the menu flow, the complete source code, sample output screenshots, limitations and future improvements, and a bibliography.
← Back to C++ Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 Live Code Editor

This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.
Next topicC++ Interview and Viva Questions Your progress: 64 / 81 (79%) · Lesson 65 / 81 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free