
Pointers and Two-Dimensional Arrays 523
12.10 POINTERS AND TWO-DIMENSIONAL ARRAYS
A matrix can represent the two-dimensional elements of an array. In order to display the elements
of the two-dimensional array using pointers, it is essential to have ‘&’ operator as a prefix with
the array name followed by element numbers.
12.13 Write a program to display array elements and their addresses using pointers.
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j=1,*p;
int a[3][3]={{1,2,3},{4,5,6},{7,8,9}};
cout<<“\n\tElements of an array with their addresses”;
p=&a[0][0];
cout<<“\n”;
for (i=0;i<9;i++,j++)
{