I have an assignment where I have to produce a rectangle or square based off of input values.
For example; the user inputs height = 3 and width = 3
***
***
***
But I also need to make a hollowed out box, so it's like this
height = 4 and width = 3
***
* *
* *
***
There is my code, and the hollowed out box.
int height, width;
int i = 0;
int j = 0;
cout << "Input digit for height: ";
cin >> height;
cout << endl;
cout << "Input digit for width: ";
cin >> width;
cout << endl;
for (i = 1; i <= height; i++)
{
for (j = 1; j <= width; j++)
cout << "*";
cout << endl;
}
_getch();
cout << endl;
for (i = 1; i <= height; i++)
{
if ((j == 0) || (j == width - 1)) {
for (j = 1; j <= width; j++)
cout << "*";
if (j =1 j -2; j++;)
cout << " ";
cout << endl;
}
_getch();re
return 0;
}
Any code critiquing is much appreciated.
Thank you all