- Give a name to findlargesmallrange() parameters
- The return statements in the if blocks cause the function to terminate early. This will most likely cause one or both of the numbers to be wrong
- If by range you mean finding their difference then it's ok, but if you wanted to find the difference of their position in the array then it's wrong
- return howfarapart; is useless. You set the value of 'howfarapart' inside the function and there is no use in returning the value in that case
when i add variables to them, the output does change. and i get a really long for largest and 0s for smallest and howfarapart.
I just noticed you don't input values in the array before calling findlargeetc(). This means that all the elements of the array are uninitialized. Every time you do stuff with uninitialized variables a fairy dies somewhere in the world
line one of your program you cant just have int&. you have to actually name the variable
Not necessarily. It's entirely possible to have unnamed parameters to a function/method. You just can't use those parameters in the body of the function (because they have no name by which to access them, obviously).
This is necessary if, for example, you're coding a method to implement an interface that's already specified to take in more parameters than your particular implementation needs.