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):

Question

The logic will allow the user to:

  1. Load a single dimensional array of size 50 with a random number
  2. The random number will range from 1 to 1,000 (you may have duplicate values)
  3. Find the highest value and the index location that it was in
  4. Find the smallest value and the index location that it was in
  5. Display the array’s contents.
  6. Display the highest value and its index location
  7. Display the lowest value and its index location
  8. 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):

Expert Answer

1 Rating

Want to see the step-by-step answer?

See Answer

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

See Answer
*Response times vary by subject and question complexity. Median response time is 34 minutes and may be longer for new subjects.

Related Computer Science Q&A

Find answers to questions asked by student like you

Q: OF 2019 x + X PG Difference between two given ti https://moodle.oakland.edu/plug X fn Course: CSI-14...

A: Program in C to calculate the order price by entering number of books, price of a book, tax per book...

Q: Write down a Unix command that will list all processes running on the computer then display informat...

A: The Unix command that is used to list all the running processes on the computer and displays the inf...

Q: in Python,  Write a program for a (very) rudimentary shooter "game". You are the only shooter and yo...

A: Import random module and use random.randint() method, which only returns integer type values in betw...

Q: Using the results of the dependency diagram (attached), table of removal and partial dependency and ...

A: Entities Identified : Student , Advisor , Appointment and Department.Entity Student is having STUDEN...

Q: Write a simple polling program that allows users to rate five topics from 1 (least important) to 10 ...

A: Pogram code #1:

Q: I can't figure this one out for the life of me. I've been stuck on it for 4 hours now... HELP! The p...

A: import re inputs = 0numbers_sum = 0 # enter the stringstring = input('Enter a string: ') # condition...

Q: In C++ why is a binary search function almost always more efficient than a linear search function?

A: In C++, binary search function is more efficient than linear search function because:Array must be s...

Q: in Python using IDLE   Now write another program that reads her inventory file, displays all data fo...

A: A Python program to display the data for each item in an inventory is given below;Program:#Print the...

Q: Why does the order of the operands (tables) matter in an EXCEPT (MINUS) query but not in a UNION que...

A: MINUSMINUS operator is used for getting the result that is present in the first table but not in the...