#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;
}
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.