// Pointers and One
dimensional arrays
#include
<iostream>
using namespace std;
const int Size = 5;
void populate(int*);
void print(const
int*);
void
print1Element(int i);
int main()
{
int array[Size];
populate(array);
print(array);
print1Element(*array);
// Print 1st element
print1Element(*(array+1));
// Print 2nd element
print1Element(*(array+Size-1));
// Print last element
}
void populate(int* a)
{
for (int i = 0; i < Size; i++)
*(a+i) = i;
}
void print(const
int* a)
{
for (int i = 0; i < Size; i++)
cout << *(a+i) << " ";
cout << endl;
}
void
print1Element(int i)
{
cout << i << endl;
}
***** Output ******