There are two completely different topics here:
- (1) You want to learn C. In C you always pass a value, but that value may be a pointer, which in effect works like pass-by-reference.
- (2) you want to calculate that summation.
You could use (1) to solve (2) but it is not a good way to do it.
You could use (2) as an example to learn (1).
But it should be very clear that (1) and (2) are not the same thing.
This is the typical way you would calculate the sum in C:
int sum = 0;
for(int i=0; i<=9; ++i)
sum += 2 + 3*i - 1;
// now sum contains the sum
If for some reason (e.g. homework requirement?) you want to pass a pointer to calculate the sum then:
void f(int* psum, int i) {
*psum += 2 + 3*i - 1;
}
...
int sum=0;
for(int i=0; i<=9; ++i)
f(&sum, i);