Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Topic: Array in C++ This program creates N random integer numbers and stores them in an array of size N where N is a user

Topic: Array in C++

This program creates N random integer numbers and stores them in an array of size N where N is a user input count with value from 1 to 100000. The generated random numbers should be in the range of 0 to 32767 (default range).

Then program sorts the array in ascending order. Using the sorted array, the program then finds the smallest number, the largest number, and the median number. The median number is the number with middle value, i.e. 50% of the numbers are above it and 50% are below it.

For example, if we have 7 numbers (odd count) that are sorted in order, the median value is the 4th number.

1, 2, 4, 6, 6, 9, 11 The median is 6 (3 numbers below 6, 3 numbers above 6)

For example, if we have 6 numbers (even count) that are sorted in order, the median value is the average of 3th and 4th number.

1, 2, 4, 6, 6, 9 The median is (4 + 6 ) / 2 = 5 (3 numbers below 5, 3 numbers above 5)

For example, if we have 6 numbers (even count) that are sorted in order, the median value is the average of 3th and 4th number.

1, 2, 4, 5, 6, 9 The median is (4 + 5 ) / 2 = 4.5 (3 numbers below 4.5, 3 numbers above 4.5)

Note that the median value may contain decimal fraction.

Program should repeat with different inputs of count.

Sample output

image text in transcribed

Program generates N random numbers from 0 to 32767 Enter the count value N (1 to 100000, or enter 0 to exit): 100000 Smallest number is 0 Largest number is 32767 edian number is 16406 Enter the N count (1 to 100000, enter 0 to exit): 1000 Smallest number is 16 Largest number is 32757 edian number is 15325.5 Enter the N count (1 to 100000, enter 0 to exit): 100 Smallest number is 285 Largest number is 31552 edian number is 15994.5 Enter the N count (1 to 100000, enter 0 to exit): 10 Smallest number is 1178 Largest number is 31548 edian number is 14330.5 Enter the N count (1 to 100000, enter 0 to exit): 3 Smallest number is 16494 Largest number is 31974 Median number is 25304 Enter the N count (1 to 100000, enter 0 to exit): 2 Smallest number is 2506 Largest number is 29986 Median number is 16246 Enter the N count (1 to 100000, enter 0 to exit): 1 Smallest number is 21377 Largest number is 21377 Median number is 21377 Enter the N count (1 to 100000, enter 0 to exit): 0 Process returned 0 (Ox0) execution time 56.061 s Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

What is meant by a nonconventional cash flow series?

Answered: 1 week ago

Question

7. Determine what feedback is provided to employees.

Answered: 1 week ago