Skip to content

Instantly share code, notes, and snippets.

@y-yu
Created November 20, 2012 11:28
Show Gist options
  • Save y-yu/4117400 to your computer and use it in GitHub Desktop.
Save y-yu/4117400 to your computer and use it in GitHub Desktop.
7-3
#include <stdio.h>
float sum_array (float array[], int n) {
float a = 0.0;
int i;
for (i=0; i<n; i++)
a += array[i];
return a;
}
int main () {
float a[] = {1.0, 2.0, 3.0};
float r = sum_array(a, 3);
printf("%f\n", r);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment