My code is giving a wrong output for the 3rd pair of vectors im finding the dot product of, although the first two are correct. (outputs - 0, 3, -3(should be 1))... I just cant find wahts wrong, i was guessing something to do with the -1 in the b array but no clues.
any help please and thankyou?

#include <stdio.h>
#include <math.h>

void vector_info(float[], float[]);
double dot(float[], float[]);

int main ()
float a[3]={1,1,0};
float b[3]={-1,1,0};
float c[3]={1,2,3};
vector_info(a ,b);
vector_info(a ,c);
vector_info(c ,b);
return 0;

void vector_info(float a[], float b[])
printf(" a . b = %4.1f\n", dot);

double dot(float a[], float b[])
return ((a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2]));

printf(" a . b = %4.1f\n", dot(a, b));

Did you miss this out? i checked the output. i got 1.0 for c.b. That is correct right?

God. I can't beleive I missed out something so simple.
Cheers its been bugging me for ages.

This question has already been answered. Start a new discussion instead.