Question: Write a program that Generates 20 random numbers between 0 and 99 and puts them in an array. Prints out the array on one line

Write a program that

Generates 20 random numbers between 0 and 99 and puts them in an array.

Prints out the array on one line with spaces between the numbers.

Sorts the numbers using any sorting technique.

Prints out the sorted array on one line with spaces between the numbers.

Asks the user for a number and searches for it in the sorted array using binary search. Repeat this step until the user enters -1.

Hint: To generate random numbers you need to include this library:

#include

rand() will generate a random number between 0 and 2147483647 !!!

To get a random number in the range 0 N-1:

int x = rand() % N ;

To get a random number in the range 1..N:

int y = 1 + rand() % N;

C++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!