Do you know how to solve/fix this array ? if so please help !
#include <iostream>
#include <string>
using namespace std;
void printArr( int a[], int cnt );
int sumArr( int a[], int cnt );
double aveArr( int a[], int cnt );
int minVal( int a[], int cnt );
int maxVal( int a[], int cnt );
int main ()
{
int arr[10];
int count;
for ( count=0 ; count<5 ; count++ )
arr[count] = count*2;
printArr( arr, count );
cout << " sum of all initialized elements in array is: " << sumArr( arr, count ) << endl;
cout << " ave of all initialized elements in array is: " << aveArr( arr, count ) << endl;
cout << " the smallest number in the array is: " << minVal( arr, count ) << endl;
cout << " the largest number in the array is: " << maxVal( arr, count ) << endl;
return 0;
}
// print all the initilized values in the array from front to back
void printArr( int a[], int cnt )
{
// your code here
}
// return the sum of the initilized values in the array
int sumArr( int a[], int cnt )
{
// your code here
return 0; // just to make it compile - you change as needed
}
// return the ave of the initilized values in the array
double aveArr( int a[], int cnt )
{
// your code here
return 0; // just to make it compile - you change as needed
}
// return the smallest number in the array
int minVal( int a[], int cnt )
{
// your code here
return 0; // just to make it compile - you change as needed
}
// return the largest number in the array
int maxVal( int a[], int cnt )
{
// your code here
return 0; // just to make it compile - you change as needed
}
You'll have to write a for loop for each function to iterate through the array. It obviously wouldn't be fair for me to write it for you. The first function is easy. All you have to do is combine cout with a for loop to iterate through the array. All you have to do for the second one is keep a running total of the elements and return it...
If you don't know how loops and cout are supposed to work, you should read the tutorials on them.