1

123
Last edited on
Load the code into a compiler, compile and then use the debugger to trace through the code to understand what's going on. Once you're done that and you then find a particular statement for which you don't understand what is happening, then ask a specific C++ question.

When you post code, please use code tags and sensible indentation. See https://www.cplusplus.com/articles/jEywvCM9/
That makes code much more readable. Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <iomanip>
#include <array>
#include <stdexcept> // for out_of_range exception class
using namespace std;

int main()
{
  const size_t SIZE{7};
  array<int, SIZE> integers1{0}; // 7-element array< int >
  array<int, SIZE> integers2{0}; // 7-element array< int >
  // NOTE: We changed integers2 to 7 elements so that operators
  // like == can be used to compare array objects.

  // print integers1 size and contents
  cout << "Size of array integers1 is " << integers1.size()
       << "\narray after initialization: ";
  for (int item : integers1) {
    cout << item << " ";
  }
  cout << endl;
}

Note that your code has comments that tell meaning of some statements.
Topic archived. No new replies allowed.