Determine the output of the following program: two dimensional array and pointer - C++ Data Type

C++ examples for Data Type:Array Pointer

Description

Determine the output of the following program: two dimensional array and pointer

Demo Code

#include <iostream>
using namespace std;
const int ROWS = 2;
const int COLS = 3;
void arr(int [] [COLS]);
int main()//  w w  w.  j  av a 2 s. c  o  m
{
   int nums[ROWS][COLS] = { {3,1,2}, {4,7,9}};
   arr(nums);
   return 0;
}
void arr(int (*val) [3])
{
   cout << endl << *(*val);
   cout << endl << *(*val + 1);
   cout << endl << *(*(val + 1) + 2);
   cout << endl << *(*val) + 1;
   return;
}

Result


Related Tutorials