C++ TutorialLesson 19Free preview
C++ Arrays
This lesson is part of C++ · All levels
Summary
This lesson discusses arrays, which are a collection of elements of the same type that are stored sequentially in memory and accessed through an index. Arrays make it easy to store a lot of data in a single variable name, such as a test score list. You also learn how to initialize an array and keep access from going out of bounds.
Key points
- Array declarations: name type[number]; e.g. int data[5];.
- The array index ranges from 0 to the sum of -1.
- The array can be filled directly with an initialisation such as int a[3] = {10, 20, 30};.
- Access beyond the limits of the index causes undefined behavior.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.