Blackroot, in three attempted answers I've seen of you today you've been at least partially wrong three times. You might want to learn a bit more first.
That said, you are right that the formatting of the program leads to confusion - but only for the programmer, not the compiler. Confuse the compiler, and it give you an error.
You are also right about the old-style headers.
As for the program:
Code:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(time(0)); // Initialize pseudorandom number generator. Without this, you'll get the
// same result every run.
const int SIZE = 7; // Typical naming convention is to put constants in all upper case.
int a[SIZE] = {0};
for(int i = 1; i < 600; ++i) { // Good practice to use prefix ++ unless postfix is required.
int index = rand() % SIZE; // 1+rand()%6 would yield numbers from 1 to 6. Array indices
// start from 0, though.
++a[index];
cout<<a[index]<<endl; // Must use the same index here - i will be quickly out of bounds.
}
for(int i = 0; i < size; ++i) { // Unless you use a broken compiler, there's nothing wrong
// with reusing the variable name here. (VC++, enable "for-scope" in the language
// options.)
cout << a[j] << " ";
}
}