Printing Rectangle

09:48 0 Comments A+ a-

Problem:
                     Printing Rectangle on Console
Solution:
# include <iostream>
# include <iomanip>
using namespace std;
int main()
{
int n,a;
cout<<"Enter the size of rectangle : ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"-";
}
cout<<endl;
a=n-2;
for(int j=0;j<a;j++)
{
cout<<"|"<<setw(n-1)<<"|"<<endl;
}
for(int k=0;k<n;k++)
{
cout<<"-";
}
cout<<endl;

return 0;

}