Multiplication Quiz Game & Guess the Number Game

๐ŸŽฎ Project 1: Multiplication Quiz Game

๐Ÿ“Œ Objective:

Create a terminal-based game that generates 5 random multiplication questions for the user. The user's score is tracked and shown at the end.


✅ Features:

  • Asks 5 random multiplication questions (1–10 range).

  • Uses a for loop for question repetition.

  • Scores the user based on correct answers.

  • Provides instant feedback.


๐Ÿ›  Tools:

  • Language: C++

  • IDE: Code::Blocks / Visual Studio / VS Code / Terminal

  • Headers used: <iostream>, <cstdlib>, <ctime>


๐Ÿง  Concepts Used:

  • for loops

  • if-else statements

  • Random number generation

  • User input/output


๐Ÿ”ค Source Code:

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main() {
    srand(time(0));  // Seed the random number generator
    int score = 0;

    cout << "๐ŸŽฏ Welcome to the Multiplication Quiz Game!\n";

    for (int i = 1; i <= 5; i++) {
        int a = rand() % 10 + 1;
        int b = rand() % 10 + 1;
        int userAnswer;

        cout << "Q" << i << ": What is " << a << " x " << b << "? ";
        cin >> userAnswer;

        if (userAnswer == a * b) {
            cout << "✅ Correct!\n";
            score++;
        } else {
            cout << "❌ Wrong. Correct answer is " << a * b << ".\n";
        }
    }

    cout << "\n๐Ÿ Quiz finished! You scored: " << score << "/5\n";
    return 0;
}

๐Ÿ“ˆ Output Example:

๐ŸŽฏ Welcome to the Multiplication Quiz Game!
Q1: What is 4 x 7? 28
✅ Correct!
Q2: What is 3 x 8? 24
✅ Correct!
Q3: What is 2 x 9? 18
✅ Correct!
Q4: What is 10 x 1? 11
❌ Wrong. Correct answer is 10.
Q5: What is 5 x 2? 10
✅ Correct!

๐Ÿ Quiz finished! You scored: 4/5

๐Ÿ“˜ Learning Outcome:

  • How to generate random numbers using rand().

  • Practice using loops and conditionals.

  • Build logic for feedback and scoring.


๐ŸŽฎ Project 2: Guess the Number Game

๐Ÿ“Œ Objective:

Create a guessing game where the user must guess a number between 1 and 100 selected randomly by the computer.


✅ Features:

  • Random number generated between 1 and 100.

  • User guesses until correct.

  • Tells the user if their guess is too high or too low.

  • Tracks number of attempts.


๐Ÿ›  Tools:

  • Language: C++

  • Headers: <iostream>, <cstdlib>, <ctime>


๐Ÿง  Concepts Used:

  • while loop

  • if-else logic

  • Random number generation

  • User input/output


๐Ÿ”ค Source Code:

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main() {
    srand(time(0));  // Initialize random seed
    int secret = rand() % 100 + 1;  // Secret number between 1 and 100
    int guess;
    int tries = 0;

    cout << "๐ŸŽฏ Welcome to 'Guess the Number'!\n";
    cout << "I'm thinking of a number between 1 and 100...\n";

    while (true) {
        cout << "๐Ÿ” Enter your guess: ";
        cin >> guess;
        tries++;

        if (guess == secret) {
            cout << "๐ŸŽ‰ Correct! You guessed it in " << tries << " tries.\n";
            break;
        } else if (guess < secret) {
            cout << "๐Ÿ“‰ Too low. Try again.\n";
        } else {
            cout << "๐Ÿ“ˆ Too high. Try again.\n";
        }
    }

    return 0;
}

๐Ÿ“ˆ Output Example:

๐ŸŽฏ Welcome to 'Guess the Number'!
I'm thinking of a number between 1 and 100...
๐Ÿ” Enter your guess: 50
๐Ÿ“‰ Too low. Try again.
๐Ÿ” Enter your guess: 75
๐Ÿ“ˆ Too high. Try again.
๐Ÿ” Enter your guess: 62
๐ŸŽ‰ Correct! You guessed it in 3 tries.

๐Ÿ“˜ Learning Outcome:

  • Build logical decision structures.

  • Learn how loops can repeat until a condition is met.

  • Understand user interaction with feedback.