#include <iostream>
usingnamespace std;
void add_4(int array[], int flag)
{
flag = 12;
int i = 0;
while (i < flag)
{
array[i] += 4;
cout << array[i] << endl;
i++;
}
}
int main ()
{
int values [] = {1,2,3,4,5,6,7,8,9,10,11,12};
add_4 (values, 12);
system ("pause");
return 0;
}
line 8: while(i <12) looks like it stops when i gets to 11, I'd say. But don't forget since it starts at array[0] 12 elements are printed out.
If you find the parameter passing confusing you could change the names to make it clear
1 2 3 4 5 6 7 8 9 10 11
void add_4(int array[], int aFlag)
{
aFlag = 12; // this is questionable, why have it??
int i = 0;
while (i < aFlag)
{
array[i] += 4;
cout << array[i] << endl;
i++;
}
}