>depends on the pass if its the first pass then 0, if second then 1, e.c.t...
Bzzt! Wrong. The correct answer is "I don't know". Though I would have accepted "indeterminate" as well. Technically you don't need i at all in that function because you pass the address of the correct array element:
void enter(int *p_arr)
{
int insert;
printf("\nplease enter the number:");
scanf("%d", &insert);
*p_arr=insert;
}
However, because you use p_arr[i] where i is indeterminate (usually this means a large number), then you're pretty sure to index the array well out of its bounds.
If you want to continue using array notation, this will solve the problem immediately (though it's technically identical to my previous fix):
void enter(int *p_arr)
{
int i = 0;
int insert;
printf("\nplease enter the number:");
scanf("%d", &insert);
p_arr[i]=insert;
}
Note that i is always 0, because p_arr always points to the element you want to initialize. You can also change your logic as Aia suggested such that the index actually makes sense:
int main()
{
int arr[5];
int i;
for ( i = 0; i < COUNT; i++ )
enter ( arr, i );
report ( arr, COUNT );
return 0;
}
void enter ( int *p_arr, int i )
{
int insert;
printf ( "\nplease enter the number:" );
scanf ( "%d", &insert );
p_arr[i] = insert;
}