#include <iostream>
usingnamespace std;
int main()
{
int x, square, c;
c = 1;
cout << "Enter side of a square: ";
cin >> x;
square = x * x;
while ( c <= square ) {
cout << "*";
if ( c % x == 0 )
cout << "\n";
c++;
}
cout << endl;
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
int square = 0;
cout << "Enter side of a square: ";
cin >> square;
for (int row = 0; row < square; row++)
{
for (int column = 0; column < square; column++)
cout << '*';
cout << endl;
}
return 0;
}
This is a nother way of doing your square. Yours is not wrong but this way might give you a better insight into how you can control what gets printed (blank or *) and where.