Skip to content

Commit

Permalink
added array to func
Browse files Browse the repository at this point in the history
  • Loading branch information
adithyaanilkumar committed Jun 29, 2020
1 parent 82378ef commit a95375c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions C/array_to_func.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//Passing array to function

#include <stdio.h>

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);
}

0 comments on commit a95375c

Please sign in to comment.