<s>[INST] C++ Programming Assignment 1
==========================

### Part 1: Printing Stars

Write a program that takes an integer as input from the user and prints a square pattern of stars (*) with that many rows and columns.

### Part 2: Printing Rectangle

Modify the program to also take the number of columns as input and print a rectangle pattern of stars.

### Part 3: Double Outline

Modify the program to also take a boolean input from the user to indicate whether the star pattern should have a double outline or not. If true, the pattern should have an outline of stars and an inner pattern of numbers.

### Part 4: Dynamic Memory Allocation

Modify the program to dynamically allocate memory for the star/number pattern, instead of using a fixed-size array.

## Step 1: Define the problem and the required input and output
We need to create a program that takes integer inputs for the number of rows and columns and prints a rectangle of stars. Additionally, it should also take a boolean input to determine if the pattern should have a double outline. The pattern should be dynamically allocated.

## Step 2: Outline the solution strategy
To solve this problem, we can follow these steps:
- Take the number of rows, columns, and the double outline boolean as input from the user.
- Dynamically allocate memory for the pattern using a 2D array.
- If the double outline option is true, print the outer border with stars and the inner pattern with numbers.
- If the double outline option is false, print the entire pattern with stars.

## Step 3: Write the code for dynamically allocating memory and printing the pattern

```cpp
#include <iostream>
#include <iomanip>

// Function to print the pattern
void printPattern(int rows, int cols, bool doubleOutline) {
    // Dynamically allocate memory for the pattern
    int** pattern = new int*[rows];
    for (int i = 0; i < rows; i++) {
        pattern[i] = new int[cols];
    }

    // Initialize the pattern with numbers
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            pattern[i][j] = (i * cols) + j + 1;
        }
    }

    // Print the pattern
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            if (doubleOutline && (i == 0 || j == 0 || i == rows - 1 || j == cols - 1)) {
                std::cout << "* ";
            } else {
                std::cout << pattern[i][j] << " ";
            }
        }
        std::cout << "\n";
    }

    // Deallocate the memory
    for (int i = 0; i < rows; i++) {
        delete[] pattern[i];
    }
    delete[] pattern;
}

int main() {
    int rows, cols;
    bool doubleOutline;

    // Take input from the user
    std::cout << "Enter the number of rows: ";
    std::cin >> rows;
    std::cout << "Enter the number of columns: ";
    std::cin >> cols;
    std::cout << "Do you want a double outline?[/INST]