{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lab5 - Computer Science 1MC3 Lab 5 Arrays ARRAYS An array...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Science 1MC3 Lab 5 – Arrays ARRAYS An array is a collection of similar items or objects stored under the same name. The individual elements of the array are called the array elements. Arrays allow us to store similar data more conveniently under one name. Arrays have a couple qualities which we should be aware of: 1. An array can only store one type of data, i.e. integers, floats, characters. . . 2. When referencing the elements of an array in C, the first element is stored at 0 not 1. DECLARTION Just like any other variable you use in c, an array has to be declared at the beginning of your program in order for the compiler to reserve the appropriate amount of memory. The declaration looks as follows data_type array_name[size_of_array]; ~or~ data_type array_name[]={array elements separated by commas -> “,”} For example an integer array declaration filled with the first ten numbers would look like this: int array[]={0,1,2,3,4,5,6,7,8,9}; However had we not filled the array initially we could also do this: int array[10];
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}