Hi there, pretty new to C++. I'm trying to write a program where I make two different arrays of random numbers, find the range (difference between largest and smallest number) in both arrays, and then take the array with the largest range, and print it on screen. I'm having issues with trying to find the array of both. I'm trying to create a loop to find the largest and smallest values of both arrays, and using those to calculate the range. However, whenever I input the code, I get an output of 0 and 999 for the small and large arrays, respectively. I'm looking around for logic errors I made, but I can't seem to find any. If anyone could give me a hand, I'd greatly appreciate it.
Hope you are not doing a crappy course where they teach you old stuff.
To make things easier it's better to use small arrays with hard-coded values so you know what the correct results are. Once this is working do it with random values.
In modern C++ you shouldn't use plain arrays, prefer std::vector or maybe std::array.
Don't write you own code for the min and max value, use std::min_element and std::max_element instead.