#include <stdio.h>

// one style of commenting uses parentheses to indicate
// that you are referring to a parameter.  See examples below.

// print (c1) followed by (width) copies of (c2)
void print_line(int width, char c1, char c2)
{
  int i;

  printf("%c", c1);
  for (i=0; i<width; i++) {
    printf("%c", c2);
  }
}

// print a row with (n) copies of +-----
void print_beam(int n, int width)
{
  int i;

  for (i=0; i<n; i++) {
    print_line(width, '+', '-');
  }
  printf("+\n");
}

// print a row with (n) copies of | followed by (width) spaces
void print_posts(int n, int width)
{
  int i;

  for (i=0; i<n; i++) {
    print_line(width, '|', ' ');
  }
  printf("|\n");
}

// print a row of squares by printing a row of beams followed
// by (height) rows of posts
void print_row(int n, int width, int height)
{
  int i;
  print_beam(n, width);

  for (i=0; i<height; i++) {
    print_posts(n, width);
  }
}

// print an (n)x(n) grid of squares, each (width) by (height)
void print_grid(int n, int width, int height)
{
  int i;

  for (i=0; i<n; i++) {
    print_row(n, width, height);
  }
  print_beam(n, width);
}

int main()
{
  int n = 8;
  int width = 6;
  int height = 3;

  print_grid(n, width, height);
  return 0;
}

