Advertisement
MichaelPetch

dot_product - SO

Sep 26th, 2022
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. float dot_product(float v1[], float v2[], int length)
  4. {
  5. int i;
  6. float result = 0.0; /* Initialize result to 0.0 */
  7. for (i = 0; i < length; i++) {
  8. result += v1[i] * v2[i];
  9. /* printf ( "%f, ", result); Are you sure you need to print this in the loop */
  10. }
  11. return result;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement