Check out example codes for "lopping over an array c++". It will help you in understanding the concepts better.

Code Example 1

for(int i = 0; i < 4; i++) {
  cout << cars[i] << "\n";
}

Code Example 2

for (int i = 0; i < arr.size(); ++i){
//use if we explicitly need the value of i
cout << i << ":\t" << arr[i] << endl;
}
for (int element : arr){
//modifying element will not affect the array
cout << element << endl;
}
for (int &element : arr){
//modifying element will affect the array
cout << element << endl;
}

Learn ReactJs, React Native from akashmittal.com