Hi, can someone help me with this. This is what I have so far !
#include <iostream>
#include <cdtg>
using namespace std;
int max(array<int,10>Data) {
int i = 0;
int count = 9;
while (count > 0) {
if (i < i+1) {
i+1;
}
else {
i;
}
i++;
count = count -1;
cout << endl;
}
int main()
{
Data data;
setRandom(data);
cout << data << endl;
cout << "Maximum value = " << max(data) << endl;
return 0;
}
simple and good, but i would recommend a little change in your code iHutch105
1 2 3 4 5 6 7
|
int highest = array[0];
for (int i=1; i<10; i++)
{
if (array[i] > highest)
highest = array[i];
}
|
because the array could only contain negativ integers and that would cause
-1 to be the "max" value or?
regards
Last edited on
i don't want to be rude, but this function simply does nothing at all.. except for the newlines
There is a general function in C++ that returns the maximum element of a sequence. It is named std::max_element and declared in <algorithm>