Writing to Arrays

Learn how to store values in an array after it has been declared as well as at the time of declaration.

Assigning values to array cells

A memory location indexed by an array (for examples grades[3]) is called a cell of that array. Just like we index an array to retrieve the value stored in it, we can also write to the same cell.

We can assign the integers 1 through 5 to the cells in our grades array like this:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy