C++ Tutorial · Chapter 11 of 13
C++ Arrays
Store lists of values.
Arrays keep multiple values under one name.
Loop from 0 to size - 1 when visiting elements.
Array sample
Try it Yourself »
#include <iostream>
using namespace std;
int main() {
int scores[5] = {90, 85, 88, 92, 95};
for (int i = 0; i < 5; i++) {
cout << "Score " << i + 1 << ": " << scores[i] << endl;
}
return 0;
}
Classroom Tips
- Index starts at 0.
- Try 2D arrays after 1D arrays.