Problem with function returning values

So I am trying to create a function that will calculate velocity from Acceleration values and time that are inputted. The problem is that I am not getting any return values from the function. I have tested it and have determined that it is actually calculating the values within the function, but not returning anything.

Vx, Vy, Vz = velocity(avgAX, avgAY, avgAZ, deltaTV, Vx, Vy, Vz);// this is what I use to call the function


//function that isn't returning values...
float velocity(float AX, float AY, float AZ, float T, float Vx, float Vy, float Vz){//calculate vx, vy, vz with equation        Vf=A*t+Vi       where Vf = final velocity, A = //acceleration, t = time, Vi = previous velocity
    Vx = AX*T+Vx;
    Vy = AY*T+Vy;
    Vz = AZ*T+Vz;
        Serial.print("VX   ");Serial.println(Vx);
        Serial.print("VY   ");Serial.println(Vy);
        Serial.print("VZ   ");Serial.println(Vz);
        Serial.print("Time   ");Serial.println(T);
    return Vx, Vy, Vz; // returns velocities in x, y, and z direction
}//END VELOCITY LOOP
return Vx, Vy, Vz; // returns velocities in x, y, and z direction

Nope. I've never seen a comma used like that before. Have you?

You can't return more than one value. If you want to get all three values out of the function the easiest way would be to pass a reference to an array as an argument to the function and have the function put the values in that.

Delta_G: return Vx, Vy, Vz; // returns velocities in x, y, and z direction

Nope. I've never seen a comma used like that before. Have you?

You can't return more than one value. If you want to get all three values out of the function the easiest way would be to pass a reference to an array as an argument to the function and have the function put the values in that.

Alternatively, you could define a struct that contains the three values and return the struct.

Delta_G: return Vx, Vy, Vz; // returns velocities in x, y, and z direction

Nope. I've never seen a comma used like that before. Have you?

Not successfully in C, but I've seen it in Perl and Python I believe. He wants to return a "list", but C doesn't have those. A structure is probably the best solution. OTOH, global variables are likely the fastest solution since the OP doesn't seem to be an expert C programmer.

Delta_G: return Vx, Vy, Vz; // returns velocities in x, y, and z direction

Nope. I've never seen a comma used like that before. Have you?

While it is unusual, the comma operator is a C/C++ operator. What it does is evaluate the left side for side effects (function call, assignment), and then ignore the result. Then it evaluates the right side and returns that as a result. So in this case, it would return Vz. It is most often used in macros that must be used as an expression, but you want side effects to occur.

MichaelMeissner:

Delta_G:

return Vx, Vy, Vz; // returns velocities in x, y, and z direction

Nope. I’ve never seen a comma used like that before. Have you?

While it is unusual, the comma operator is a C/C++ operator. What it does is evaluate the left side for side effects (function call, assignment), and then store the result.

eh? store where?

WizenedEE:

MichaelMeissner:

Delta_G: return Vx, Vy, Vz; // returns velocities in x, y, and z direction

Nope. I've never seen a comma used like that before. Have you?

While it is unusual, the comma operator is a C/C++ operator. What it does is evaluate the left side for side effects (function call, assignment), and then store the result.

eh? store where?

Whoops, I meant ignore the result. Good catch. I'll fix the article.

Other languages work like that . C and C++ don’t.

I suggest you find and study a basic explanation of how C and/or C++ function calls work.

If you want to “return” three floats from your function, there are many different ways to do it.
Perhaps the most straightforward is to create three floats in the calling program, pass pointers to
the floats to the function, and the function can set the values it has calculated. Like this:

...
float x,y,z ;
calculateVelocity(  &x, &y, &z );
//  x,y,z now contain the velocity
...



void calculateVelocity( float* x, float* y, float* z  )
{
   //  calculate the velocities  vx,vy,vz  somehow
   *x = vx ;
   *y = vy ;
   *z = vz ;
   return ;
}

If you want to "return" three floats from your function, there are many different ways to do it. Perhaps the most straightforward is to create three floats in the calling program, pass pointers to the floats to the function, and the function can set the values it has calculated.

Far simpler is to use reference arguments:

float x, y, z;
velocity(x, y, z);
void velocity(float &x, float &y, float &z)
{
   x = 1.0;
   y = 2.4;
   z = -3.6;
}

Nope. I've never seen a comma used like that before. Have you?

Python, most elementary form:

a, b = b, a # swap two vars