Ok. I'll dissect the code for you. When I code, I pseudo in English first and then transform that into C++.
print a row of "0"'s
each row contains a column.
we iterate through each column.
once we are done with all the columns in this row
we proceed to the next row.
I think you may have kept the "i" variable in your nested "for" statement - this is why your square didn't work properly and some of your formatting is off.
#include<iostream>
usingnamespace std;
int main()
{
int row, i, j, width, spaces;
cout <<"Enter the number of rows: ";
cin >> row;
cout <<"Enter the rectangle width: ";
cin >> width;
// Print a row of O's
for(i=0; i<row; i++)
{
// Each row has columns iterate them
for(j=0; j<width; j++)
{
// Print an "O"
cout << "O";
}
// Done with this row, proceed to next row
cout << endl;
}
system("pause");
return 0;
}