1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
void part7(const int[], int);//function prototype
const int arraySize = 20;
//initialize array
int a[arraySize] = {3, 55,2,9,35,36,1,212,24,311,7,101,26,42,555,52,17,18,57,554};
part7(a, arraySize);//function call
void part7(const int b[], int size)//function definition
{
cout << endl;
cout << setw(20) << "Part VII " << endl << endl;
cout << "Element " << setw(12) << "Value " << endl;
for(int i = 0; i < size; i++)
{
if(b[i] == b[i*3])
cout << setw(6) << i << setw(12) << b[i] << endl;
}
}
|