Module 6 - Arrays and Vectors

BLUF - Bottom Line Up Front

In C++, an array is a collection of elements of the same data type that are stored in contiguous memory locations. Arrays are useful for storing and manipulating large amounts of data in a structured way.

Arrays in C++ are fixed-size, which means that the number of elements in the array cannot be changed once it is defined. To iterate over all the elements in an array, you can use a for loop

A vector is a dynamic array that can grow or shrink in size at runtime. It is part of the C++ Standard Library and is defined in the <vector> header. Unlike regular arrays, vectors are more flexible because they can dynamically adjust their size.

Module 6 Learning Objectives

  • Identify the purpose of arrays

  • Declare and initialize arrays

  • Demonstrate manipulating data into arrays

  • Distinguish the restrictions on array processing

  • Pass an array as a parameter to a function

  • Demonstrate how to search and sort an array

  • Use auto declarations

  • Evaluate range-based for loops

  • Use C-strings to input data into—and output data from—a C-string

  • Define parallel, two-dimensional, and multidimensional arrays

  • Learn about Vectors

COSC-1336 / ITSE-1302 Computer Science - Author: Dr. Kevin Roark