for loop trouble (beginner)
I am trying to output the following pattern:
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
Here is what i have been able to come with:
#include <iostream>
using namespace std;
int main()
{
int column=16;
int row=8;
for (int counter = 0; counter < row; counter++){
for (int count = 0; count < column; count++){
if ( count % 2 == 0)
cout << "*";
else
cout << " ";
}
cout << endl;
}
return 0;
}
I dont know how to get every other row shifted 1 space. The exercise i am doing says to only use 3 output statements
cout <<'*';
cout <<" ";
cout << endl;
I would like to add, this isnt homework. I am trying to learn C++ on my own (and with your help). I have about 8 books on the subject (one is wrox- beginning C++). This particular exercise is out of an old Deitel & Deitel book, C++ How To Progream (3rd Edition).
Please dont just give a solution, try to walk me thru the solution. I am sure its something math related, i just cant figure it out and instead of giving up completly, decided to ask for help.
Thanks
Chris
|