COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
array2D_func.cpp File Reference
#include <iostream>
#include <iomanip>
Include dependency graph for array2D_func.cpp:

Go to the source code of this file.

Functions

int main ()
 
void print_2d_array (const int a[][5], int numRows)
 

Function Documentation

◆ main()

int main ( void )

Definition at line 19 of file array2D_func.cpp.

20{
21 const int nRows = 3;
22 const int nCols = 5;
23
24 int array2D[nRows][nCols];
25 int i, j;
26
27 // assign initial values
28 for (i = 0; i < nRows; ++i)
29 for (j = 0; j < nCols; ++j)
30 array2D[i][j] = nCols*i + j;
31
32 print_2d_array( array2D, nRows );
33
34 return 0;
35}
void print_2d_array(const int a[][5], int numRows)

References print_2d_array().

Here is the call graph for this function:

◆ print_2d_array()

void print_2d_array ( const int a[][5],
int numRows )

Definition at line 6 of file array2D_func.cpp.

7{
8 // print out array contents
9 for (int i = 0; i < numRows; ++i)
10 {
11 for (int j = 0; j < 5; ++j)
12 cout << setw(3) << a[i][j] << ' ';
13 cout << endl; // start new line for each row
14 }
15
16}

Referenced by main().

Here is the caller graph for this function: