You are on page 1of 1

Program for an output of hollow square

#include<iostream.h>
#include<conio.h>

void hollowsquare( int side );

void main()
{
int side;

cout << "Enter an integer between 1 and 20 to determine the size\n";
cout << "of the sides of the square.\n\n";
cin >> side;

hollowsquare(side);

getch();
}

void hollowsquare( int side)

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

}

You might also like