#include
using namespace std;
void f(int *n, int num);
int main()
{
int i, nums[10];
for(i=0; i < 10; i++) nums[i] = i+1;
cout << "Original contents: ";
for(i=0; i < 10; i++) cout << nums[i] << ' ';
cout << '\n';
f(nums, 10); // compute cubes
cout << "Altered contents: ";
for(i=0; i<10; i++) cout << nums[i] << ' ';
return 0;
}
void f(int *n, int num)
{
while(num) {
*n = *n * *n ;
num--;
n++;
}
}
Original contents: 1 2 3 4 5 6 7 8 9 10
Altered contents: 1 4 9 16 25 36 49 64 81 100