Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started