A console-based, 30-question multiple-choice quiz written in C++ as a Semester 2 project. The program registers a student, runs an untimed quiz across seven subject areas with a two-round skip system, prints a result sheet with a letter grade, and finishes by generating a text-based completion certificate.
- Features
- Tech Stack
- How It Works
- Question Bank
- Project Structure
- Prerequisites
- Getting Started
- Usage
- Scoring and Grades
- Known Limitations
- License
- Student registration form with 10 fields (name, father's name, age, gender, CNIC / Form-B, email, address, hobby, level, status)
- Level-aware validation: School (grade 1-10), College (year 11 or 12), or Uni (year 1-4 and semester 1-8)
- 30 multiple-choice questions with four options each, grouped into seven categories
- Screen is cleared between questions, and each question shows its category and position (for example, "Question 3 of 30")
- Input validation for answers: only
A,B,C,D, orS(case-insensitive) is accepted - Two-round skip system: questions skipped with
Sare asked again after the first pass, and skipping a second time scores zero for that question - Result sheet listing the category, the user's answer, the correct answer, and a status for every question
- Score, percentage, and letter grade calculation
- Quiz completion certificate that includes the student's details, score, grade, and a randomly generated verification code
| Category | Details |
|---|---|
| Language | C++ |
| Standard library | <iostream>, <string>, <vector>, <iomanip>, <algorithm>, <ctime>, <cstdlib> |
| Platform headers | <windows.h> on Windows, <unistd.h> on other systems |
| Compiler | Any C++11 (or later) compiler such as g++ |
The program has no external dependencies.
All logic lives in main.cpp and is organized into three parts.
| Component | Type | Responsibility |
|---|---|---|
User |
class | Collects and stores the registration details through fillDetails() and validates the level, grade, year, and semester combination |
Question |
struct | Holds the category, prompt, four options, the correct answer, the user's answer, and skip flags |
QuizEngine |
class | Stores the question bank, runs the quiz, handles the skip rounds, calculates the grade, prints the result sheet, and generates the certificate |
Two small helper functions, waitSec() and clearScreen(), are defined with a _WIN32 preprocessor check. On Windows they use Sleep() and cls; on other systems they use sleep() and clear.
- The program shows a banner and asks the user to type
yesto continue. Any other input exits the program. - The student registration form is displayed and the details are stored in a
Userobject. - The 30 questions are added to the
QuizEngine. - Round 1: every question is asked in order. The user answers with
A-Dor skips withS. - Round 2: if any questions were skipped, they are asked again with a warning that skipping again gives 0 for that question.
- The result sheet is displayed with the score, percentage, and grade.
- After pressing Enter, the completion certificate is printed.
Questions are defined directly in main() through addQuestion(category, prompt, optionA, optionB, optionC, optionD, correctLetter).
| Category label | Subject | Questions |
|---|---|---|
GK |
General Knowledge | 5 |
AI/ML |
Artificial Intelligence and Machine Learning | 5 |
Islam |
Islamic Studies | 5 |
Pak Study |
Pakistan Studies | 5 |
Science |
Science | 6 |
English |
English | 2 |
Math |
Mathematics | 2 |
| Total | 30 |
To add or change a question, edit the corresponding quiz.addQuestion(...) call in main() and recompile. The banner text ("30 Questions", "7 topics") is hardcoded, so update it if the question count or category count changes.
quiz-master/
|-- main.cpp # Complete application: User, Question, QuizEngine, and main()
|-- LICENSE # MIT License
`-- README.md
- A C++ compiler such as g++ (for example, MinGW on Windows)
- A terminal that supports the
clscommand (Windows) or theclearcommand (Linux and macOS)
Clone the repository and move into it:
git clone https://github.com/stackiid/quiz-master.git
cd quiz-masterCompile the program:
g++ -Wall main.cpp -o quiz-masterRun it:
# Windows PowerShell
.\quiz-master.exe
# Windows Command Prompt
quiz-master
# Linux and macOS
./quiz-master- Type
yesat the start screen (lowercase, exactly as shown) and press Enter. - Fill in the registration form. For the level prompt, enter
School,College, orUni(case-insensitive), then provide the requested grade, year, or semester. - Answer each question by typing
A,B,C, orDand pressing Enter. TypeSto skip a question and return to it later. - After the skipped questions are re-attempted, review the result sheet and press Enter to generate the certificate.
Example question screen:
Category : [GK] | Question 1 of 30
------------------------------------------------
Which is the largest ocean?
A) Atlantic
B) Indian
C) Pacific
D) Arctic
------------------------------------------------
[Enter A / B / C / D or S to skip for later]
Your Answer:
Example result sheet layout:
================ RESULT SHEET ================
Category Your Ans Correct Status
-----------------------------------------------
GK C C Correct
GK A B Wrong
...
-----------------------------------------------
Score : <score> / 30
Average : <percentage>%
Grade : <grade>
===============================================
The certificate lists the student's name, father's name, age and gender, CNIC, level (with year, grade, or semester), and status, followed by the score, grade, and a verification code in the format QM-XXXX.
Each correct answer adds one point. Skipped questions that are skipped again in round 2 earn no points and are marked SKIPPED on the result sheet. The percentage is score / 30 * 100.
| Percentage | Grade |
|---|---|
| 90 and above | A+ |
| 80 to below 90 | A |
| 70 to below 80 | B |
| 60 to below 70 | C |
| 50 to below 60 | D (Pass) |
| Below 50 | F (Fail) |
These points describe the current behavior of the code:
- Results and registration data are not saved; everything exists only for the duration of the run.
- The verification code on the certificate is a random 4-digit number generated at the end of the quiz. It is not stored or checked against anything.
- The address, email, and hobby fields are collected in the registration form but are not printed on the certificate.
- The age, grade, year, and semester prompts do not handle non-numeric input.
- Answers are read one character at a time, so typing more than one character at an answer prompt is not treated as a single invalid answer.
- Questions are always asked in the same fixed order, and the answer options are not shuffled.
This project is licensed under the MIT License. See the LICENSE file for details.
Copyright (c) 2026 Ubaid Ahmad