From a95375cd91e9fe75bbf13fe8a9beec6ed791f217 Mon Sep 17 00:00:00 2001 From: adithyaanilkumar Date: Mon, 29 Jun 2020 09:39:43 +0530 Subject: [PATCH] added array to func --- C/array_to_func.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 C/array_to_func.c diff --git a/C/array_to_func.c b/C/array_to_func.c new file mode 100644 index 0000000..a68cb1a --- /dev/null +++ b/C/array_to_func.c @@ -0,0 +1,24 @@ +//Passing array to function + +#include + +float largest(float a[], int n); + +void main() +{ + float array[4] = {2.5,-4.5,1.5,3.5}; + float answer; + answer = largest(array,4); + printf("%f\n",answer); +} + +float largest(float a[], int n) +{ + int i; + float max; + max = a[0]; + for(i = 1; i < n; i++) + if(max < a[i]) + max = a[i]; + return(max); +} \ No newline at end of file