Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- /*
- An array is a list of variables
- arrays have sizes
- the size goes in between the hard brackets
- */
- int num_list[3];
- //Array subscripts begin at zero
- num_list[0] = 777;
- num_list[1] = 8;
- num_list[2] = 42;
- //num_list[1000] = 2452; // This is a crash - array index out of bounds exception
- cout << "Element at subscript 0 - " << num_list[0] << endl;
- cout << "Element at subscript 1 - " << num_list[1] << endl;
- cout << "Element at subscript 2 - " << num_list[2] << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement