# ๐Ÿ”ง C++ Intermediate Exam Created ## โœ… Exam Details **Exam ID:** `cpp-intermediate-v1` **Title:** C++ Intermediate - OOP & Practical Coding **Subject:** C++ **Difficulty:** Intermediate **Duration:** 90 minutes **Passing Score:** 70% --- ## ๐Ÿ“Š Exam Structure **Total Questions:** 6 **Total Points:** 110 points ### Question Type Breakdown - โœ… **1** Single Choice (10 points) - โœ… **1** Multiple Choices (15 points) - โœ… **1** True/False (10 points) - โœ… **1** Simple Coding Task (20 points) - โœ… **1** Simple Coding Task (25 points) - โœ… **1** Advanced Coding Exercise (30 points) **Theory Questions:** 35 points (auto-graded) **Coding Tasks:** 75 points (requires manual grading) --- ## ๐Ÿ“š Section 1: OOP Theory & Concepts (3 questions, 35 points) ### Q1: Virtual Function Control (Single Choice, 10 points) **Topic:** C++11 'final' keyword **Question:** How to prevent derived class from overriding a virtual function? **Answer:** Use the 'final' keyword **Tests:** Understanding of modern C++ features ### Q2: Rule of Five (Multiple Choices, 15 points) **Topic:** Special member functions in C++11 **Question:** Which are included in the Rule of Five? **Correct Answers:** - A: Copy constructor โœ“ - B: Move constructor โœ“ - C: Move assignment operator โœ“ - D: Default constructor (NOT in Rule of Five) **Tests:** Understanding of resource management ### Q3: Pure Virtual Functions (True/False, 10 points) **Topic:** Abstract classes **Question:** Must pure virtual function be implemented in base class? **Answer:** False (implemented in derived classes) **Tests:** Understanding of polymorphism --- ## ๐Ÿ’ป Section 2: Practical Coding Tasks (3 tasks, 75 points) ### Task 1: Recursive Factorial (Simple Coding, 20 points) **Objective:** Implement recursive factorial function **Requirements:** - Function name: `factorial` - Parameter: non-negative integer n - Return type: `unsigned long long` - Must use recursion **Test Cases:** ```cpp factorial(0) โ†’ 1 (public) factorial(1) โ†’ 1 (public) factorial(5) โ†’ 120 (public) factorial(10) โ†’ 3628800 (hidden) ``` **Skills Tested:** - Recursion understanding - Base case handling - Correct return type - Edge case handling (0!) **Grading:** Automatic based on test cases --- ### Task 2: Palindrome Checker (Simple Coding, 25 points) **Objective:** Implement palindrome detection with case and space handling **Requirements:** - Function name: `isPalindrome` - Parameter: `std::string` - Return type: `bool` - Ignore case and spaces **Test Cases:** ```cpp isPalindrome("racecar") โ†’ true (public) isPalindrome("hello") โ†’ false (public) isPalindrome("A man a plan a canal Panama") โ†’ true (public) isPalindrome("Race Car") โ†’ true (hidden) ``` **Skills Tested:** - String manipulation - Character comparison - Case conversion - Space filtering - Two-pointer technique or string reversal **Grading:** Automatic based on test cases --- ### Task 3: Vector2D Class (Advanced Coding Exercise, 30 points) **Objective:** Design and implement a complete 2D vector class **Requirements:** Implement class with: 1. **Constructor:** `Vector2D(double x, double y)` 2. **operator+:** Vector addition 3. **operator\*:** Dot product (returns `double`) 4. **magnitude():** Returns vector length 5. **normalize():** Returns unit vector in same direction **Example Usage:** ```cpp Vector2D v1(3, 4); Vector2D v2(1, 2); Vector2D v3 = v1 + v2; // (4, 6) double dot = v1 * v2; // 11 double mag = v1.magnitude(); // 5 Vector2D unit = v1.normalize(); // (0.6, 0.8) or (3/5, 4/5) ``` **Test Cases:** ```cpp Vector2D(3, 4) + Vector2D(1, 2) โ†’ Vector2D(4, 6) (public) Vector2D(3, 4) * Vector2D(1, 2) โ†’ 11 (public) Vector2D(3, 4).magnitude() โ†’ 5 (public) Vector2D(6, 8).normalize().magnitude() โ†’ 1 (approx) (hidden, 2ร— weight) ``` **Skills Tested:** - Class design - Operator overloading - Mathematical operations - Member function implementation - const correctness **Grading Rubric:** - Constructor: 20% - operator+ overloading: 20% - operator* overloading: 20% - magnitude() method: 20% - normalize() method: 20% **Grading:** Manual review with rubric + automated tests **Starter Code Provided:** ```cpp class Vector2D { private: double x, y; public: // Your implementation here }; ``` --- ## ๐ŸŽฏ Topics Covered ### OOP Concepts - Virtual functions and polymorphism - 'final' keyword (C++11) - Rule of Five (C++11) - Pure virtual functions - Abstract classes - Special member functions ### Coding Skills - **Recursion:** Base cases, recursive calls - **String Manipulation:** Case handling, character filtering - **Class Design:** Encapsulation, operator overloading - **Mathematical Operations:** Vector math, normalization - **Modern C++:** Smart syntax, const correctness --- ## โš ๏ธ Important Notes ### Auto-Grading **Questions 1-3 (Theory):** โœ… Auto-graded **Question 4 (Factorial):** โœ… Auto-graded (test cases) **Question 5 (Palindrome):** โœ… Auto-graded (test cases) **Question 6 (Vector2D):** โš ๏ธ **Requires manual grading** ### Manual Grading Required - The Vector2D class (Q6) has a rubric for manual assessment - Auto-grading will run test cases - Instructor should review code quality - Check: proper operator overloading, const correctness, code style --- ## ๐ŸŽ“ Difficulty: Intermediate ### Why Intermediate? **Theory:** - Covers C++11+ features (final, move semantics) - Requires understanding of advanced OOP - Not just basic syntax **Coding:** - Recursion (non-trivial) - String processing with filtering - Full class implementation with operator overloading - Mathematical computations - Multiple member functions **Not Beginner Because:** - Requires OOP mastery - Operator overloading needed - Modern C++ features tested - Complex string manipulation **Not Advanced Because:** - No templates or metaprogramming - No concurrency - No advanced memory management - Standard problems with clear solutions --- ## ๐Ÿ“Š Expected Performance ### Score Ranges - **90-100%** - Strong intermediate C++ skills - **80-89%** - Good understanding, minor issues - **70-79%** - Passing, needs practice - **60-69%** - Below passing, review OOP & coding - **<60%** - Need to strengthen fundamentals ### Time Management - **Q1-Q3 (Theory):** 10-15 minutes total - **Q4 (Factorial):** 10-15 minutes - **Q5 (Palindrome):** 15-20 minutes - **Q6 (Vector2D):** 35-45 minutes - **Review:** 5-10 minutes - **Total:** 75-90 minutes --- ## ๐Ÿ”— Integration with Learning Plan This exam aligns with: - **C++ Learning Plan - Phase 2: OOP** - Covers Modules 2.1-2.3, 2.5 - Tests: Classes, operator overloading, polymorphism - Prepares for Phase 3 (Modern C++) ### Prerequisites Before taking this exam, complete: 1. C++ Phase 1 (all modules) - Must be mastered 2. Module 2.1: Classes & Objects 3. Module 2.2: Advanced Constructors 4. Module 2.3: Operator Overloading 5. Module 2.5: Polymorphism (virtual functions) ### After Passing 1. Continue to Module 2.6: Templates Basics 2. Study Module 2.7: Exception Handling 3. Move to Phase 3: Modern C++ 4. Take advanced exam (future) --- ## ๐Ÿš€ How to Access ### Via Web Interface 1. Go to http://localhost 2. Login or register 3. Navigate to "Available Exams" 4. Select "C++ Intermediate - OOP & Practical Coding" 5. Click "Start Exam" ### Via API ```bash # Get exam details curl http://localhost/api/exams/cpp-intermediate-v1/ ``` --- ## ๐Ÿ’ก Preparation Tips ### For Theory Questions - Review C++11 features: final, override, move semantics - Understand Rule of Five vs Rule of Three - Master virtual functions and pure virtual functions - Know when to use which feature ### For Coding Task 1 (Factorial) - Practice recursion with base cases - Handle edge case: 0! = 1 - Use correct return type (unsigned long long) - Test with small and large inputs ### For Coding Task 2 (Palindrome) - Review string methods: tolower(), isspace() - Practice two-pointer technique - Handle mixed case correctly - Filter out non-alphanumeric characters ### For Coding Task 3 (Vector2D) - Review operator overloading syntax - Understand dot product formula - Practice sqrt() for magnitude - Remember to normalize: divide by magnitude - Make methods const where appropriate --- ## ๐Ÿ“ Mathematical Formulas for Vector2D ### Vector Addition ```cpp (xโ‚, yโ‚) + (xโ‚‚, yโ‚‚) = (xโ‚ + xโ‚‚, yโ‚ + yโ‚‚) ``` ### Dot Product ```cpp (xโ‚, yโ‚) ยท (xโ‚‚, yโ‚‚) = xโ‚xโ‚‚ + yโ‚yโ‚‚ ``` ### Magnitude ```cpp ||(x, y)|| = โˆš(xยฒ + yยฒ) ``` ### Normalization ```cpp normalize(x, y) = (x/||v||, y/||v||) ``` --- ## ๐Ÿ“ˆ All Available Exams 1. **Python Easy** - 10 questions (auto-graded) 2. **Python Easy 15Q** - 15 questions (auto-graded) 3. **Python Intermediate** - 50 questions (auto-graded) 4. **C++ Easy** - 20 questions (auto-graded) 5. **C++ Intermediate** - 6 questions (mixed grading) โญ **NEW** 6. **Linear Algebra Medium** - 10 questions (auto-graded) **Total:** 6 exams across 3 subjects! --- ## ๐ŸŒŸ Exam Features ### Modern Question Types โœ… Single choice โœ… Multiple choices with partial credit โœ… True/False โœ… Simple coding tasks (auto-tested) โœ… Advanced coding exercises (rubric + tests) โœ… "I Don't Know" option ### Grading Features โœ… Automatic scoring for theory โœ… Test case validation for simple code โœ… Rubric-based for complex code โœ… Detailed feedback โœ… Code quality assessment ### Coding Environment โœ… Syntax highlighting โœ… Auto-save every 10 seconds โœ… Test case visibility (public/hidden) โœ… Starter code provided โœ… Clear requirements --- **Your C++ Intermediate exam is ready! Test your OOP and coding skills! ๐Ÿ”ง๐Ÿ’ป** **Created:** October 21, 2025 **Status:** โœ… Published and Available **Access:** http://localhost **Note:** Question 6 requires manual grading for full assessment