Display scores in rows of four

I have to display scores from array in a rows of four. But my code does not display properly. So, I need help to fix it. This is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

#include <iostream>
using namespace std;

int main()
{
    const int SIZE = 18;
    int score[SIZE] = { 55, 74, 93, 84, 64, 72, 69, 78, 87, 84, 72, 33, 83, 68, 62, 51, 88, 90 };

    for (int count = 0; count < SIZE; count++)
    {
        cout << score[count] << " ";
        if (score[count + 1] % 4 == 0)     // Display scores in rows of four
            cout << endl;
    }
}
One possibility:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
using namespace std;

int main()
{
  const int SIZE = 18;
  int cr = 3;
  int score[SIZE] = { 55, 74, 93, 84, 64, 72, 69, 78, 87, 84, 72, 33, 83, 68, 62, 51, 88, 90 };

  for (int count = 0; count < SIZE; count++)
  {
    cout << score[count] << " ";
    if (count == cr)
    {
      cout << endl;
      cr += 4;
    }
  }
}
Works perfect. Thank you for your help
Topic archived. No new replies allowed.