Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function that counts how many times one of its parameters appears in an array. The function's prototype is int countAll(int numbers[], int size,

Write a function that counts how many times one of its parameters appears in an array. The function's prototype is

int countAll(int numbers[], int size, int target);

where numbers is the array of numbers,

size is the size of the array,

and target is the number the function is counting in the array.

For the array elts, whose elements are {1, 2, 9, 4, 1, 5, 1, 7}

countAll(elts, 8, 1) returns 3 because 1 appears 3 times in the array.

Declare the random number generator functions as global variables. Use default_random_engine and uniform_int_distribution. Use the random number generator functions and countAll to write the following functions:

Write a function that returns an array of unique random numbers. By unique, I mean that no number appears more than once in the array. The function's prototype is

void generate(int numbers[], int size)

where numbers is the array of numbers and size is the size of the array.

Write a function that returns the number of elements that appear in both arrays. The function prototype is

int countMatches(int numbers1[], int numbers2[], int size)

where we the assume that the sizes of the two arrays are greater than or equal to the second parameter size.

For the pair of arrays {7, 5, 2, 3, 1} and {2, 3, 4, 6, 1}, countMatches returns 3 and

for the pair of arrays {1, 2, 3, 5,7} and {1, 2, 3, 4, 6}, countMatches returns 3.

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

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions

Question

=+ What do you think about the Feds recent policy decisions?

Answered: 1 week ago

Question

=+What is the Fed doing? Why?

Answered: 1 week ago