functions for finding max and min with an array

-Don't understand why it's not working. PLEASE HELP!!!!



#include<iostream>
#include<fstream>
#include<ctime>
#include<cstdlib>
#include<cmath>

using namespace std;

int computemax(double t[10], double i);//function prototype
int computemin(double t[10], double i);
int computesum(double t[10], double i);
void odd_even(double t[10], double i);

int main()
{
//Declare variables
ofstream fout("output.txt");
int t[10];//the array
int i;//the loop
srand((unsigned)time(0));
//Assign value to array t
for(i=0; i<10; ++i)
{

//int random_integer = rand();//produce random number
t[i] = rand();//random_integer;
fout << t[i] << endl;
}

fout.close();



return 0;
}

int computemax(double t[10], double i)//Function header
{
int max=0;
for(i=0; i<10; ++i)
{
if(max>t[i])
max=t[i];
}
return max;
}//end function

int computemin(double t[10], double i)//function header
{
int min=0;
for(int i=0; i<10; ++i)
{
if(min<t[i])
min=t[i];
}
return min;
}//end function

int computesum(double t[10], double i)
{
int sum=0;
for(i=0; i<10; ++i)
{
sum=sum + t[i];
}
return sum;
}//end of function

void odd_even(double t[10], double i)
{
int odd=0;
int even=0;
for(i=0; i<10; ++i)
{
if(t[i]%2 = 0)//count even numbers
++even;
else
++odd;//count odd numbers
}
cout << "There are" << " " << even << " " << "numbers." << endl;
cout << "There are" << " " << odd << " " << "numbers." << endl;
}//end function
if(max>t[i])
should be
if(max<t[i])

int min=0;
should be
int min=INT_MAX;

INT_MAX lives in <climits>
code tags please
Topic archived. No new replies allowed.