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

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( void )

Definition at line 6 of file pointer_array.cpp.

7{
8 int a[10], i;
9
10 for ( i = 0; i < 10; ++i )
11 a[i] = 2 * i;
12
13 int * p = a;
14
15 for ( i = 0; i < 10; ++i )
16 cout << p[i] << ' ';
17 cout << endl;
18
19
20 int * q = &a[0];
21 for ( i = 0; i < 10; ++i )
22 cout << q[i] << ' ';
23 cout << endl;
24
25 p = &a[2];
26 cout << p[3] << endl;
27
28 return 0;
29}