-
average
please, help, why doesn't it work?
P S srednia mean average
Code:
#include <math.h>
#include <stdio.h>
#define N 10
double srednia(int [], int);
int main() {
int tablica[N] = {23, 41, 432, 543, 41, 1543, 76, 21, 54, 12};
int wynik = 0;
int i;
double sr = srednia(tablica, N);
printf("%f", sr/N);
return 0;
}
double srednia(int t[], int n){
int i;
int wynik;
for(i = 0; i < n; i++){
wynik += t[i];
}
return wynik/n;
}
-
Change line 20 to:
Code:
printf( "%f\n", sr );
And line 38 to:
Code:
return (double)wynik / n;