Free tutorials & notes in Hindi & English · Clean code examples 🧰 मुफ़्त PDF और फ़ोटो टूल्स →
🔴 Advanced  ·  Lesson 64

C++ Mini Projects

Mini project क्यों बनाएँ?

Loops, classes और files के बारे में पढ़ना एक बात है; उन्हें जोड़कर चलता हुआ program बनाना — यहीं C++ असल में समझ आती है। Mini project से आपके पास दिखाने को कुछ होता है — Class 12 practical exam, BCA/B.Tech lab submission या internship interview के लिए। इस page पर बढ़ती कठिनाई वाले आठ projects, हर एक में इस्तेमाल होने वाले concepts, और फिर एक पूरा project step by step है।

8 project ideas

#Projectमुख्य featuresConceptsLevel
1Student report cardStudents जोड़ना, 5 marks, total, percentage, grade, merit listclass, vector, sort, functionsBeginner
2Quiz gameFile से questions, score, timer, high scorefile handling, vector, randomBeginner
3Library managementBooks जोड़ना/खोजना/issue/return, देर से लौटाने पर fineclasses, file handling, searchIntermediate
4Bank account systemAccount खोलना, deposit, withdraw, statement, PIN checkencapsulation, validation, filesIntermediate
5Tic-tac-toe2-player board, जीत/draw पहचान2D arrays, functions, loopsBeginner
6Inventory / shop billingProducts, stock, GST के साथ bill, low-stock alertmap, iomanip, filesIntermediate
7Hotel room bookingRoom types, booking dates, availability, invoiceinheritance, vector, datesAdvanced
8Contact bookContacts जोड़ना/बदलना/हटाना/खोजना, नाम से sortmap या vector, strings, filesBeginner

किसी भी project की planning

  1. Features की सूची लिखें — user क्या कर सकता है (जोड़ना, देखना, खोजना, हटाना, save)।
  2. Data पहचानें — एक record में क्या होगा (roll, name, marks) → वही class बनेगी।
  3. Menu design करें — user की choice पर switch वाला do … while loop।
  4. एक समय में एक feature बनाएँ और अगला शुरू करने से पहले test करें।
  5. File saving आख़िर में जोड़ें, जब memory में सब चल जाए।
  6. गलत input संभालें — numbers की जगह अक्षर, खाली list, दोहराए roll numbers।

पूरा project: Student Report Card

नीचे का project पूरा है और किसी भी C++17 compiler पर compile होता है। यह students को vector में रखता है, grades निकालता है, merit list print करता है और data students.txt में save करता है ताकि records अगली बार भी मिलें।

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: मूल क्रम बना रहे
    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

Project कैसे काम करता है

  • **Student class** हर record का data रखती है और total(), percentage(), grade() निकालती है — गणना एक ही जगह।
  • **readInt()** हर number जाँचता है और user के अक्षर लिखने पर भी संभल जाता है (cin.clear() + cin.ignore())।
  • **vector<Student>** students जुड़ने के साथ बढ़ता है; array का fixed size नहीं।
  • **save() / load()** ofstream / ifstream से data को students.txt में runs के बीच रखते हैं।
  • Merit list vector की copy बनाकर lambda से sort करती है, मूल क्रम नहीं बदलता।
  • Menu switch वाला do … while loop है — console projects का standard ढाँचा।

इसे आगे बढ़ाने के ideas

  • Subject के नाम रखें और एक student का पूरा report card print करें।
  • std::getline से space वाले नाम allow करें।
  • Edit और delete options जोड़ें।
  • हर subject का class average, सबसे ज़्यादा और सबसे कम दिखाएँ।
  • Code को student.h, student.cpp और main.cpp में बाँटें (देखें header files)।

Project report में क्या रखें

  1. Certificate और acknowledgement (school के format में)
  2. उद्देश्य और परिचय
  3. Hardware और software requirements (जैसे Windows 10, Code::Blocks 20.03 with GCC)
  4. Classes और functions का विवरण
  5. Menu flow / flowchart
  6. पूरा source code
  7. हर menu option के output screenshots
  8. सीमाएँ और आगे का scope
  9. Bibliography (textbook, इस्तेमाल किए CodingEasily lessons)

Student projects की आम गलतियाँ

  • Turbo C++ के conio.h, clrscr(), gotoxy() या graphics.h इस्तेमाल करना — modern compilers पर compile नहीं होते।
  • Input validation न होना — अक्षर लिखते ही program अनंत loop में।
  • Class की जगह हर जगह global variables।
  • सिर्फ exit पर data save करना — crash होने पर सब खो जाता है; हर बदलाव के बाद save करें।
  • बिना समझे project copy करना — viva में पकड़ में आ जाता है।
🏋️ अभ्यास

Project 4 (bank account) चुनें। Private balance, गलत amount मना करने वाले deposit() और withdraw(), menu और file saving के साथ Account class बनाएँ। फिर inheritance से SavingsAccount class जोड़ें जो हर महीने ब्याज जोड़े।

सारांश

  • Mini projects classes, vectors, functions, menus और files को एक program में जोड़ते हैं।
  • Features → data → menu की planning करें, फिर एक-एक feature बनाकर test करें।
  • हर input जाँचें और हर बदलाव के बाद file में save करें।
  • ऊपर का report card project एक पूरा, modern template है जिसे आप बढ़ा सकते हैं।

संबंधित: file handling, classes और objects, vector, C++ practice programs, C mini projects।

अक्सर पूछे जाने वाले प्रश्न (FAQ)

Class 12 student के लिए अच्छा C++ mini project कौन-सा है?
Student report card system, library management system या bank account system सबसे अच्छे हैं। हर एक में classes, arrays या vectors, functions, file handling और menus आते हैं — ठीक वही topics जो CBSE Computer Science syllabus में हैं — और एक-दो हफ्ते में पूरा हो जाता है।
C++ mini project में कौन-से concepts होने चाहिए?
अच्छे project में classes और objects, constructors, loop के अंदर switch वाला menu, input validation, records रखने के लिए vector या arrays, और fstream से file handling होनी चाहिए ताकि data अगली बार भी मिले। Inheritance या operator overloading bonus हैं।
C++ project में data हमेशा के लिए कैसे save करें?
<fstream> की file handling लें: program बंद होते समय या हर बदलाव के बाद ofstream से records लिखें, और शुरू होते समय ifstream से पढ़ें। हर line में एक record वाला साधारण text format debug करने में सबसे आसान है।
C++ project report में क्या लिखें?
Title और उद्देश्य, इस्तेमाल हुआ hardware और software, हर class और function का विवरण, menu का flow, पूरा source code, sample output screenshots, सीमाएँ और आगे के सुधार, और bibliography।
← Back to C++ Tutorial
🔗

Share this topic with a friend

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

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

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

💻 लाइव कोड एडिटर

इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.
अगला topicC++ Interview and Viva Questions आपकी प्रगति: 64 / 81 (79%) · Lesson 65 / 81 आगे बढ़ें →

यह lesson कैसा लगा?

आपकी राय से हम content और बेहतर बनाते हैं।

अपना review और सुझाव लिखें (वैकल्पिक)

Review approve होने के बाद आपका नाम और शहर इसके साथ public दिख सकते हैं। Email या phone न लिखें।

▶ CodingEasily on YouTube

Video से सीखें – आसान Hindi में

चुनी हुई video: RDBMS भाग 3 – Class XI Commerce IT

▶ Channel subscribe करें