Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 13th, 2012  |  syntax: None  |  size: 0.69 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /* Zach Williams
  2. Dot Product function */
  3.  
  4. #include <stdio.h>
  5.  
  6. int main() {
  7.     double vector_1i, vector_1j, vector_1k;
  8.     double vector_2i, vector_2j, vector_2k;
  9.     printf("What are the three components of the first vector? \n");
  10.     scanf("%lf%lf%lf", &vector_1i, &vector_1j, &vector_1k);
  11.     printf("What are the three components of the second vector? \n");
  12.     scanf("%lf%lf%lf", &vector_2i, &vector_2j, &vector_2k);
  13.     double a = vector_1i*vector_2i;
  14.     double b = vector_1j*vector_2j;
  15.     double c = vector_1k*vector_2k;
  16.     double dotproduct = a+b+c;
  17.    
  18.     printf("The scalar product of the two vectors is %.1lf \n", dotproduct);
  19.     system("PAUSE");
  20.     return 0;
  21.    
  22. }