I was able to make a code that displays a rectangle, whenever I input the width and length. But I have a problem, there must be an "x" in the center of the hollow rectangle, whenever the user inputs an ODD length, and ODD width, for example, 5 by 7. Thanks.
my code:
#include<iostream>
using namespace std;
int main()
{
int length=0, width=0;
cout << "Enter the length of the hollow rectangle: ";
cin>>length;
cout << "Enter the width of the hollow rectangle: ";
cin>>width;
for(int i=0; i<length; i++)
{
for(int j=0; j<width; j++)
{
if(i==0 || i==length-1 || j==0 || j==width-1)
cout << "*";
else
cout << " ";
}
cout<<endl;
}
system("pause");
return 0;
}