Write a C program Write functions that return the following values. (Assume that a and n are
parameters, where a is an array of int values and n is the length of the array.) (a) The largest
element in a. (b) The average of all elements in a. (c) The number of positive elements in a.
Solution
#include
#include
int largest(int* ,int );
float avg(int*,int);
int positive(int*,int);
int main()
{
int n,i=0,lar,count;
float average;
printf("Enter the number of elements in the array ");
scanf("%d",&n);
int a[n];
for(i=0;i0)
{
count+=1;
}
}
return count;
}

Write a C program Write functions that return the following values. .pdf

  • 1.
    Write a Cprogram Write functions that return the following values. (Assume that a and n are parameters, where a is an array of int values and n is the length of the array.) (a) The largest element in a. (b) The average of all elements in a. (c) The number of positive elements in a. Solution #include #include int largest(int* ,int ); float avg(int*,int); int positive(int*,int); int main() { int n,i=0,lar,count; float average; printf("Enter the number of elements in the array "); scanf("%d",&n); int a[n]; for(i=0;i0) { count+=1; } } return count; }