Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The program is suppose to print a square then have a space and a hollow square n

ID: 3624932 • Letter: T

Question

The program is suppose to print a square then have a space and a hollow square net to it like below

This program prints a filled and hollow square.
Enter the length of a side: 5
***** *****
***** * *
***** * *
***** * *
***** *****

below is my source code, my question is how do i get the second box hollow?

#include
using namespace std;

int main() {
cout << "This program prints a filled and hollow square ";
cout << "Enter the lenght of a side: ";
int length;
cin >> length;

for (int row = 1; row <= length; row++) {
for (int col = 1; col <= length; col++) {
cout << "*";
}
cout << " ";
for(int col=1; col<=length; col++)
{
cout << "*";
}
cout << endl;
}

return 0;
}

This program prints a filled and hollow square

Enter the lenght of a side: 5

***** *****

***** *****

***** *****

***** *****

***** *****







Explanation / Answer

#include<iostream>
using namespace std;

int main() {
cout << "This program prints a filled and hollow square ";
cout << "Enter the lenght of a side: ";
int length;
cin >> length;

for (int row = 1; row <= length; row++)
{
for (int col = 1; col <= length; col++)
{

cout << "*";
}
cout << " ";
for(int col=1; col<=length; col++)
{
    if((row>1 && row <length) && (col>1 && col <length))
cout << " ";
else
cout << "*";

}
cout << endl;
}
return 0;
}

// ENJOY CHEERS.......