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
| # | Project | Key features | Concepts used | Level |
|---|---|---|---|---|
| 1 | Student report card | Add students, enter 5 marks, total, percentage, grade, merit list | class, vector, sort, functions | Beginner |
| 2 | Quiz game | Questions from a file, score, timer, high score | file handling, vector, random | Beginner |
| 3 | Library management | Add/search/issue/return books, fine for late return | classes, file handling, search | Intermediate |
| 4 | Bank account system | Open account, deposit, withdraw, statement, PIN check | encapsulation, validation, files | Intermediate |
| 5 | Tic-tac-toe | 2-player board, win/draw detection | 2D arrays, functions, loops | Beginner |
| 6 | Inventory / shop billing | Products, stock, bill with GST, low-stock alert | map, iomanip, files | Intermediate |
| 7 | Hotel room booking | Room types, booking dates, availability, invoice | inheritance, vector, dates | Advanced |
| 8 | Contact book | Add/edit/delete/search contacts, sort by name | map or vector, strings, files | Beginner |
How to plan any project
- Write the feature list — what the user can do (add, view, search, delete, save).
- Identify the data — what one record holds (roll, name, marks) → that becomes a class.
- Design the menu — a
do … whileloop with aswitchon the user's choice. - Build one feature at a time and test it before starting the next.
- Add file saving last, once everything works in memory.
- 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.
#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;
}How the project works
- **
Studentclass** keeps each record's data and calculatestotal(),percentage()andgrade()— 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()** useofstream/ifstreamso data is kept instudents.txtbetween runs. - Merit list copies the vector and sorts it with a lambda, leaving the original order untouched.
- Menu is a
do … whileloop withswitch, 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.cppandmain.cpp(see header files).
What to include in the project report
- Certificate and acknowledgement (school format)
- Aim and introduction
- Hardware and software requirements (e.g. Windows 10, Code::Blocks 20.03 with GCC)
- Description of classes and functions
- Menu flow / flowchart
- Complete source code
- Output screenshots for each menu option
- Limitations and future scope
- Bibliography (textbook, CodingEasily lessons you used)
Common mistakes in student projects
- Using
conio.h,clrscr(),gotoxy()orgraphics.hfrom 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.
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?
Which concepts should a C++ mini project include?
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?
<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.