1. ## Could someone please explain why all the alternatives work?

I am trying to get a better understanding of pointers.
Could someone please explain why all the alternatives work?
And are there any more alternatives?

Code:
```#include <stdio.h>

//float summate(float*);// A
//float summate(float[]);// B
float summate(float z[]);

int main()
{
float result;
float a[] = {23.4, 55, 22.6, 3, 40.5, 18};
result = summate(&a[0]); // could just be summate(a);
printf("Result = %.2f", result);
return 0;
}

//float summate(float* x) // C
float summate(float  x[])
{
float sum = 0.0;
for (int i = 0; i < 6; ++i)
{
sum += x[i];
}
return sum;
}```

2. Re: Could someone please explain why all the alternatives work?

What I am asking is, could someone please describe how the alternatives work? What actually happens and why, when the lines, that I have marked, are executed by the system.

-----

3. Well, first you have to understand that this declares a function named summate having a parameter of type pointer to float, and with a return type of float:
Code:
`float summate(float z[]);`
Yes, you see what you might recognise as array notation syntax, but here it declares a pointer, not an array.

This is the same thing, except that it uses what you might recognise as pointer notation syntax, and omits the parameter name:
Code:
`float summate(float*);`
Since you're only declaring the function without defining it at this point, omitting the parameter name is perfectly fine.

This is also the same thing, except that it goes back to what you might recognise as array notation syntax, but omitting the parameter name, which as before is permitted:
Code:
`float summate(float[]);`
This comment here is absolutely correct because in this context, the array would be implicitly converted to a pointer to its first element, which is of course another way of saying &a[0]:
Code:
`result = summate(&a[0]); // could just be summate(a);`

4. This is my knowledge no more, no less.
IF: int a, *p; a = 20; p = &a;
printf("p : %x\n", p ); // shows address
printf("*p : %d\n", *p ); //shows a
The value of a pointer (p = &a) is the address of another variable
p* shows the value of another variable by means of its address

----

now what is (int *) ?
now what is (int[]) ? how am I to understand that a pointer is being declared? A pointer to what?

now what is (int *) ?
This doesn't appear in the context you provided. I'm guessing that you're asking this question in the context of your post #1, for example, you're asking what does (int *) mean in this declaration:
Code:
`void foo(int *);`
The answer is that it is a parameter type list that declares that the function named foo has a parameter of type pointer to int.

now what is (int[]) ?
Again, I'm assuming that you're asking something along the lines of what does (int[]) mean in this declaration:
Code:
`void foo(int[]);`
The answer is that it is a parameter type list that declares that the function named foo has a parameter of type pointer to int. This particular syntax tends to be used when dealing with an array, but this is not required (i.e., you can use the int* syntax instead, and the caller doesn't have to pass an array).

how am I to understand that a pointer is being declared?
You have to understand that in this context, i.e., when you see this syntax used in a parameter type list, it means that the function has a pointer parameter. You understand it by memorisation, by looking at examples and exaplanations, etc, because you're learning the syntax and semantics of a language. For example, how are you to understand what the English word "understand" means? You could look up a definition of "understand" in an English dictionary, possibly in conjunction with sentence examples in which "understand" is used (which might be provided by the dictionary).

A pointer to what?
A pointer to whatever the argument of the function points to. Look back at your post #1: in the function call summate(&a[0]), &a[0] is the argument to summate. Therefore, the parameter named x points to a[0] for that function call. In the function's forward declaration, the same parameter is named z, which is confusing, so don't do that: keep the parameter names consistent.

6. Laserlight, I am immensely grateful for your response. I need a few things out of the way before I can digest it. But prior to that:

Code:
`int main()`
Code:
```{
float result;
float a[] = {23.4, 55, 22.6, 3, 40.5, 18};
result = summate(&a[0]); // could just besummate(a);
printf("Result = %.2f", result);
return 0;
}
```

in
summate(a); is 'a' a pointer to array a?

7. No, a is an array of 6 float elements. But when it is passed as an argument to summate, it is converted to a pointer to its first element.

8. Laserlight, I would like to thank you very much for your insight giving responses!

9. In the code example where I show alternative parameters (that all work), the parameter is a pointer.
In "summate(a)" the 'a' is a pointer to the first element of 'array a'. But "&a[0]"will also work as the parameter of the function.
How can an an "address of the first element" and a "pointer to the first element" effectively be the same thing?

10. "No, a is an array of 6 float elements. But when it is passed as an argument to summate, it is converted to a pointer to its first element." ---> When I park my car where it is not allowed and a policeman approches it to leave a fine under its windscreen wiper, it is converted into a bicycle.