CSCI 1300 Chapter 8: Arrays

26 views4 pages

Document Summary

Structures for storing sequences of values of the same type. When you define an array, you can specify the initial values. For example, double values[] = { 32, 54, 67. 5, 29, 34. 5, 80, 115, 44. 5, 100, 65 }; When you supply initial values, you don"t need to specify the array size. The compiler determines the size by counting the values. const int size = 10; It is a good idea to use a named constant for the size. int numbers[size]; int size = 10; int numbers[size]; Caution: in standard c++, the size must be a constant. This array definition will not work with all compilers. int squares[5] = { 0, 1, 4 }; if you supply fewer initial values than the size, the remaining values are set to 0. The values stored in an array are called its elements. Each element has a position number, called an index.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents