
Untitled
By: a guest on
May 13th, 2012 | syntax:
None | size: 0.69 KB | hits: 16 | expires: Never
/* Zach Williams
Dot Product function */
#include <stdio.h>
int main() {
double vector_1i, vector_1j, vector_1k;
double vector_2i, vector_2j, vector_2k;
printf("What are the three components of the first vector? \n");
scanf("%lf%lf%lf", &vector_1i, &vector_1j, &vector_1k);
printf("What are the three components of the second vector? \n");
scanf("%lf%lf%lf", &vector_2i, &vector_2j, &vector_2k);
double a = vector_1i*vector_2i;
double b = vector_1j*vector_2j;
double c = vector_1k*vector_2k;
double dotproduct = a+b+c;
printf("The scalar product of the two vectors is %.1lf \n", dotproduct);
system("PAUSE");
return 0;
}