All pastes #757314 Raw Edit

Stuff

public c v1 · immutable
·published 2007-11-01 04:55 UTC
rendered paste body
#include <stdio.h>float scalarproduct(int n, float *x, float *y){  float scalar;  int i;  for (i = 0; i < n; i++)    scalar += (x[i] * y[i]);  //printf("Scalar product is: %f\n",scalar);  return scalar;}int main(){  float x[4] = {1.0,2.0,3.0,4.0};  float y[4] = {4.0,3.0,2.0,1.0};  float scalar;  scalar = scalarproduct(4, x, y);  printf("Scalar product is: %f\n", scalar);}