Sinux1

T7E1.cpp

Apr 9th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7.     /*
  8.     An array is a list of variables
  9.     arrays have sizes
  10.     the size goes in between the hard brackets
  11.     */
  12.  
  13.     int num_list[3];
  14.     //Array subscripts begin at zero
  15.     num_list[0] = 777;
  16.     num_list[1] = 8;
  17.     num_list[2] = 42;
  18.     //num_list[1000] = 2452; // This is a crash - array index out of bounds exception
  19.  
  20.     cout << "Element at subscript 0 -  " << num_list[0] << endl;
  21.     cout << "Element at subscript 1 -  " << num_list[1] << endl;
  22.     cout << "Element at subscript 2 -  " << num_list[2] << endl;
  23.  
  24.  
  25.     return 0;
  26. }
Add Comment
Please, Sign In to add comment