Define a function drawRectangle with the following prototype: 

void drawRectangle(int width, int height, int offest); 
The function will print a rectangle made out of height rows with '@' character repeated width times on each row. The first @ on each row will be preceded by offset spaces. That means the whole rectangle will be offset from the left side of the command window.. For example a call to drawRectangle(3,5,6); will look produce this: 

          @@@
          @@@
          @@@
          @@@
          @@@

Your function should call drawRow() from the previous exercise. (You don't need to implement drawRow() here. It's provided by the driver.) 

Here is the previous exercise:

Define a function drawRow() with the following prototype: 

void drawRow(int numSpaces, int numChars);
The function will print numSpaces spaces, followed by the '@' character repeated numChars times. Lastly, a newline will be printed. 

For example, a call to drawRow(16,10); will print the following line of characters (ending with a newline): 
        @@@@@@@@@@

Notice there are 16 spaces, follwed by 10 @'s. 

Here is my solution for the drawRow() exercise:

void drawRow(int numSpaces, int numChars)
{
    for(; numSpaces > 0; numSpaces--)
    {
        cout << " ";
    }
    for(; numChars > 0; numChars--)
    {
        cout << "@";
    }
    cout << endl;
    return;
}

Here is my solution for the drawRectangle() exercise:

void drawRectangle(int width, int height, int offset)
{
    for (int i = 0; i < height; i++)
    {
        drawRow(offset,width);
    }
    cout << endl;
}

You posted your solution, but is there a question somewhere?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.