This won't answer your question, however, I think it's still worth pointing out.
1.) First, for your code:
1 2 3 4 5 6
|
for (int i = 0; i < 10; i++){
randomNumberArray [i] = rand () % 20 + 1;
}
for (int i = 0; i < 10; i++){
cout << randomNumberArray [i] << endl; // displaying array for testing purposes.
}
|
You should be able to put it into one for loop like so:
1 2 3 4
|
for (int i = 0; i < 10; i++) {
randomNumberArray [i] = rand () % 20 + 1;
cout << randomNumberArray [i] << endl; // displaying array for testing purposes.
}
|
It should serve the same function.
2.) Also, I recommend being consistent with your bracket placement. While it's
not required, it does make your code more neat and readable. There are two common formats:
1 2 3
|
if (boolVal == true) {
}
|
and
1 2 3 4
|
if (boolVal == true)
{
}
|
Both formats are equally good.
3.) Indent. You already do this for most stuff which is good. The only part you didn't do this for was after the int main() {
For example:
1 2 3 4 5
|
int main() {
// Your code here. It's indented.
return 0;
}
|
4.) At the end of int main(), generally it's good to put "return 0;". Why? To be honest, I'm not 100% sure the reason as I'm still learning myself. But I believe it has to do with int main having a data type (int), so it's expected to return a value like all functions except void (you'll learn more about this later).
Format:
1 2 3 4
|
int main() {
return 0;
}
|
Other than that, looks pretty good to me! I'm sure someone on the forums will be able to help you figure out your question. :)