Question: Write a complete C + + program that does the following: Declares an array of integers with capacity 2 0 . Passes the array to
Write a complete C program that does the following:
Declares an array of integers with capacity
Passes the array to a f
unction called fillWithDistinctNums that takes a D array and an integer capacity as input. The f
unction fills the
array with random integers between and inclusive BUT each number must be different than all previous entries in the array. In
other words, no number can appear more than once in the array.
Generate the entries as random numbers and repeatedly make new numbers until a legal entry is found
HINT: You
will need to use a while loop inside the for loop. For each new number generated, you
will check all previous entries in
the array to see if the new number is a duplicate of a previous number already in the array.
Passes the filled array to a f
unction called printArray that takes the D array and its capacity as input and prints all elements in the
array separated by a space.
Example main f
unction that uses fillWithDistinctNums:
int main
int nums;
fillWithDistinctNumsnums;
printArraynums;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
