Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Include the standard (STD) 
//  input and output (IO) header
#include <stdio.h>

// Main function
// Returns: Integer
int main() {
  
  int numberArray[10];

  // In C++, the length of an array can
  //  be dynamically calculated 
  //  through dividing the length 
  //  (in bytes) of the array
  //  by the length (in bytes) of the 
  //  first entry.
  int arrayLength = (sizeof(numberArray)/sizeof(numberArray[0]));

  for(int i = 0; i < arrayLength; i++) {
    numberArray[i] = i;
  }

  printf("The length is %i \n", arrayLength);

  int counter = 0;

  while(counter < arrayLength) {

    printf("The entry is %i \n", counter);

    counter++;
  }

  // Return 0
  return 0;

}
gcc version 4.6.3