Hollow rectangle, with X at its center whenever the entered values are both ODD numbers..

#include<iostream>

using namespace std;

int main()
{
int length=0, width=0, cwidth = width/2, clength = length/2;
cout<<"This program will print a hollow rectangle, using the user's
desired length and width. "<<endl;
cout<<endl;
cout << "Enter the length: ";
cin>>length;
cout << "Enter the width: ";
cin>>width;
cout<<" "<<endl;
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;
}
cout<<endl;
system("pause");
return 0;
}
*****
* *
* *
* x *
* *
* *
*****

for example this is 5x7

Also here
https://www.cplusplus.com/forum/general/268749/

Spamming the question won't make it answered any quicker.
Topic archived. No new replies allowed.