Good Evening,
I am having problems with the code below, what I need to do is have the array show 15 lines of value (alpha[0] through alpha[14], then the next set of 15 and so on, on its own line. When I run the code it loops indefinitely. Any help that can be offered is greatly appreciated, I have put the entire program after the code I need help with.
Verbatim directions: Output the value of the alpha so that 15 components per line are printed.
The point of arrays is to not have to repeat yourself 15 times :)
Try replacing lines 27-30 with this, let me know if that helps:
1 2 3 4 5 6
for (int i = 0; i < 50; i++)
{
cout << alpha[i];
if (i % 15 == 14)
cout << '\n'; // New line every 15 elements
}
PS: Avoid global variables like what you have on lines 5-7. Move those declarations into main().
PPS: The reason it loops indefinitely is because your for loop had (counter = 0; counter < 50; counter +15)"counter + 15" doesn't do anything. You'd need to assign it. But this is not the right approach, because you'd still be going out of bounds of your array unless 50 is divisible by 15 (it's not).