From 188232f7328fe1b40812079ae3bac0ed1c9dc699 Mon Sep 17 00:00:00 2001 From: fdai7968 Date: Thu, 8 Feb 2024 18:23:10 +0000 Subject: [PATCH] code for average --- src/average_median/average_median.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/average_median/average_median.c b/src/average_median/average_median.c index 8b13789..fcb7664 100644 --- a/src/average_median/average_median.c +++ b/src/average_median/average_median.c @@ -1 +1,12 @@ +#inlcude "average_median.h" +#include +#include +#include +double average(const double *data, int n) { + double sum = 0.0; + for (int i = 0; i < n; ++i) { + sum += data[i]; + } + return sum / n; +}