//To compile: g++ [source_code.cpp] -o [exec_file] // replace [soure_code.cpp] with the filename, // replace [exec_file] with the executable file name // i.e., g++ c++_basics.cpp -o run //Note: if the output redirect is not given, i.e., the "-o [exec_file]" part is missing // then the default executable name is a.out //To run the program, simply run the executable: ./[exec_file] // i.e., ./a.out (if your executable file is a.out) #include //input/output stream library using namespace std; void populate_array(int arr[], int size){ for (int i = 0; i < size; ++i) { arr[i] = 100 + i; } return; } void print_array(int arr[], int size){ for (int i = 0; i < size; ++i) { cout << arr[i] << endl; } cout << endl; return; } void populate_array_2D (float arr[][5], int rows){ for (int i = 0; i < rows; ++i) { for (int j = 0; j < 5; ++j) { arr[i][j] = 4.5 + i * j; } } return; } void print_array_2D (float arr[][5], int rows){ for (int i = 0; i < rows; ++i) { for (int j = 0; j < 5; ++j) { cout << &arr[i][j] << " "; } cout << endl; } cout << endl; return; } //main function: entry point of the program int main() { int array[10]; float array_2D[5][5]; populate_array(array, 10); print_array(array, 10); cout << "array name: " << array << endl; populate_array_2D(array_2D, 5); print_array_2D(array_2D, 5); char arr_char[5]; arr_char[0] = 'h'; arr_char[1] = 'h'; arr_char[2] = 'h'; arr_char[3] = 'h'; arr_char[4] = '\0'; cout << (int*) arr_char << endl; return 0; }