The logic will allow the user to: Load a single dimensional array of size 50 with a random number The random number will range from 1 to 1,000 (you may have duplicate values) Find the highest value and the index location that it was in Find the smallest value and the index location that it was in Display the array’s contents. Display the highest value and its index location Display the lowest value and its index location Allow the user to execute this application multiple times (some sort of loop?) You will need one for loop to load the array as well as one or two for loops to search that array. The rand also has a “nasty” tendency to create the same results repeatedly in an exe. To avoid that, we have to “shuffle the deck” every time. This ensures that all numbers are an equal probability of appearing and not the same set of values (would create a boring game). // Add this to "shuffle the deck" every time to ensure that // different values could occur else the exe produces the same results. srand( (unsigned)time( NULL ) ); The above has to run only one time within the source code, appearing before the rand call. The array is used to store and retrieve values for later use in the program. What type of loop would you need? Can you check the highest and smallest in one for loop? Output Example Index # 89 - 97 Index # 90 - 826 Index # 91 - 310 Index # 92 - 495 Index # 93 - 750 Index # 94 - 176 Index # 95 - 175 Index # 96 - 466 Index # 97 - 611 Index # 98 - 185 Index # 99 - 325 Highest Value is 996 at Index Location # 41 Lowest Value is 5 at Index Location # 23 Run this Again (Y or N):
The logic will allow the user to:
- Load a single dimensional array of size 50 with a random number
- The random number will range from 1 to 1,000 (you may have duplicate values)
- Find the highest value and the index location that it was in
- Find the smallest value and the index location that it was in
- Display the array’s contents.
- Display the highest value and its index location
- Display the lowest value and its index location
- Allow the user to execute this application multiple times (some sort of loop?)
You will need one for loop to load the array as well as one or two for loops to search that array.
The rand also has a “nasty” tendency to create the same results repeatedly in an exe. To avoid that, we have to “shuffle the deck” every time. This ensures that all numbers are an equal probability of appearing and not the same set of values (would create a boring game).
// Add this to "shuffle the deck" every time to ensure that
// different values could occur else the exe produces the same results.
srand( (unsigned)time( NULL ) );
The above has to run only one time within the source code, appearing before the rand call.
The array is used to store and retrieve values for later use in the program. What type of loop would you need?
Can you check the highest and smallest in one for loop?
Output Example
Index # 89 - 97
Index # 90 - 826
Index # 91 - 310
Index # 92 - 495
Index # 93 - 750
Index # 94 - 176
Index # 95 - 175
Index # 96 - 466
Index # 97 - 611
Index # 98 - 185
Index # 99 - 325
Highest Value is 996 at Index Location # 41
Lowest Value is 5 at Index Location # 23
Run this Again (Y or N):

Trending now
This is a popular solution!
Step by step
Solved in 3 steps









