### Need help On Project

I have to write a program that find the biggest and smallest number in an array.
Here is Source Code
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859`` ``````#include #include #include void loadArray(); void smallestLocation(int, int []); void largestLocation(int, int []); void printSmallestLargest(int [], int, int); using namespace std; int main (){ return 0; } void loadArray(){ srand(time(NULL)); int max= rand() % 75 + 25; int iArray [100]; for (int i=0; ilarge) large= iArray[i]; lLocation=i; } } void largestLocation(int &max, int iArray[]){ int small= 100, sLocation; for (int i=0; i

Here is requirements:
 1. loadArray --- Is a function that will store values in the array. The maximum number of values to be stored in the array should be between 25 and 100. Generate a random number in the interval [25,100] which will be the actual number of values contained in the array. This value will be the actual number of legitimate values stored in the array. a. Once this value has been determined, use the random number generator to store values in your integer array from 1 to 1000. 2. smallestLocation --- is a function that returns the subscript or location in the array of the smallest number in the list. 3. largestLocation --- is a function that returns the subscript or location in the array of the largest number in the list. 4. printSmallestLargest --- is a function that will print the largest number and the smallest number in the list. Note: This function should have as parameters the array and the subscripts of the smallest and largest items in the array. Do not use a separate variable to contain the largest or smallest number in the list.

I'll fix function names as they are redundant.
How can i make it run through each function in order then quit?
Last edited on
......
To run them, you need to call the function you want.
void LoadArray seems redundant because iArray is not a global variable. Any your attempt will be destroyed when the function finished the performing. And all other functions, they should have a returning value, such as in your case (int <function name>())
In my opinion, your code should be changed. Here is an example :
 ``1234567`` ``````int *LoadArray(){ [...] return iArray;} //All other functions int (){ [...] return result}``````

The size of this array is always 100, so all remaining functions using this array you should always specify the size is 100 (You can change and make a new parameter for function LoadArray if you need)
For example, usage of the code
 ``123456`` ``````int main(){ int *iArray = LoadArray(); int smallLoc = smallestLocation(100,iArray); int largeLoc = largestLocation(100, iArray); printSmallestLargest(iArray,smallLoc, largeLoc) }``````

"Smallest" returns sLocation and 'Largest' returns lLocation. Do you know returning value of a function?? :)
Last edited on
the values of the array are unknown, that's why theirs random number generators. so sLocation and lLocation are the location in the array where the smallest and largest value are.

we get an automatic zero if we use global variables. so i need to know how to run each function and pass parameters correctly

i think i have iArray passed to other functions as a parameter