How can i make loops post a 10 by 10 square of stars
I need to write a program that displays a 10 by 10 square of stars....can you help?(ima newb)
to loop the output of 10 starts, you just want to loop the output of 1 star 10 times. Using a for loop to count from 0 to 9, that is
1 2
|
for (int i = 0; i < 10; ++i)
cout << '*';
|
now you just want to print that 10 times, so put another for loop counting from 0 to 9 around that;
1 2 3 4 5 6 7 8 9
|
#include <iostream>
using namespace std;
int main() {
for(int i = 0; i < 10; ++i) {
for (int j = 0; j < 10; ++j)
cout << "* ";
cout << endl;
}
}
|
note: I added a space after the star output to make it closer to a square
Thanks mate :)
@gumber: Don't just give solutions please...just give hints, people learn better that way.
Topic archived. No new replies allowed.