Simple program to print two squares

Hey guys, I was wondering if someone could help me out with my assignment which is two print a total of two squares, a solid and a hollow one , which i have managed to do so correctly. But i also have to make them print side by side with a space between them, how can i go about doing that? My code below prints both the squares but one below the other. Thanks for the help in advance! Stay awesome :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;

int main()
{
int size = 0;

{
cout << "Enter the size of the square:  ";
cin >> size;
}
for (int row = 1; row <= size; row++)
{
for (int col = 1; col <= size; col++)
{
if (row > 1 && row < size && col > 1 && col < size)
cout << " ";
else
cout << "*";
}
cout << "\n";

}
cout << endl;
for (int row = 1; row <= size; row++)
    {
        for (int col = 1; col <= size; col++)
        {
            cout << "*";
        }
        cout << endl;
    }
    
return 0;
}
Last edited on
You have now:
for each row
  for each column
    print character (hollow)
  endline

for each row
  for each column
    print character (filled)
  endline

How about:
for each row
  for each column
    print character (hollow)
  space
  for each column
    print character (filled)
  endline

Print first row of hollow square.
Print space.
Print first row of solid square
Print newline
Print second row of hollow square.
Print space.
Print second row of solid square
...
Topic archived. No new replies allowed.