How can I find max value of array using pointers? I must use cpp+header combo and [] is not allowed. Here is a part of the code.
main.cpp
const int NUMBERS = 30;
int main() {
int array[NUMBERS] = { 1, 3, 6, 9 };
sort(array, array + NUMBERS);
...
std::cout << max_v1(array, NUMBERS) << std::endl;
std::cout << max_v2(array, array + NUMBERS) << std::endl;
}
I got arrays.cpp and under it:
int max_v1(int *ptr, int size)
{
//TODO
}
int max_v2(int *firstptr, int *lastptr)
{
//TODO
}