Write functions that return the following values Assume that
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.
Please write the function without using iostrem because it doesn\'t work with codeblocks. Thank you.
Solution
#include<stdio.h>
 #include<conio.h>
 int largestElement(int[],int);
 int average(int[],int);
 int numberOfPostiveElements(int[],int);
 int main(){
 int arr[]={2,4,-3,4,5,2};
 largestElement(arr,6);
 average(arr,6);
 numberOfPostiveElements(arr,6);
 return 0;
 }
   
 int largestElement(int a[],int n){
 int great;
 for(int i=0;i<n;i++){
 if(a[i]>a[i+1])
 great=a[i];
 }
 return great;
 }
   
 int average(int a[],int n){
 int sum=0;
 int avg;
 for(int i=0;i<n;i++){
 sum=sum+a[i];
 }
 avg =sum/n;
 return avg;
   
 }
 int numberOfPostiveElements(int a[],int n){
   
 int count=0;
   
 for(int i=0;i<n;i++){
 if(a[i]>0)
 count++;
 }
 }
   

