### Writing function to return min/max of given test arrays

Hi all,
I'm new to c++ and was given an assignment to make a function that will find the max and min of given test arrays. I was given a header file to download and the file contains two functions - one that increases the size of the console so there's more room to graph and one that plots values in an array using character graphics. It also contains several arrays containing test data. the test arrays are:
a. const int TEST_SIZE = 10;
b. double test1 [TEST_SIZE],test2 [TEST_SIZE], test3[TEST_SIZE], test4[TEST_SIZE];

Here's the code I have so far. I'm guessing I'm pretty far off but could someone point me in the right direction?

#include "stdafx.h"
#include <string>
#include <cmath>
#include "char_plotting.h"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
double min140, max140;
const int TEST_SIZE=10;
double test1[TEST_SIZE],test2[TEST_SIZE],test3[TEST_SIZE],test4[TEST_SIZE];

for(int i=0;i<TEST_SIZE;i++)
{
if(min140>test1[i])
{
min140=test1[i];
}
else if(max140<test1[i])
{
max140=test1[i];
}
}

cout << "Max Number is:" << max140 << endl;
cout << "Min Number is:" << min140 << endl;

system ("pause");

return 0;
}
Firstly all your arrays are empty arrays. You need to fill in values probably by reading from a file or from console.

Also, in your for loop you seem to be finding the minimum and maximum element of test1 array. Remove the 'else' from the loop.

 ``1234567891011121314`` ``````// initialize the values for min140 and max140. min140 = test1[0]; max140 = test1[0]; for(int i=1;itest1[i]) { min140=test1[i]; } if(max140
Topic archived. No new replies allowed.