Question: A ) ( 1 5 Points ) Define a function int [ ] GetRandom ( int N , int a , int b ) that

A)(15 Points) Define a function int[] GetRandom(int N, int a, int b) that returns an array of size N, of which all the elements are random integers between a and b.
B)(15 Points) Define a function int Smallest(int[] Y, ref int pos) that takes an integer array Y as input and returns the smallest element in the array. It also uses pass-by-reference to find the index, pos, of the smallest element.
C)(20 Points) Use the functions in A) and B) as part of a C# Console App program that analyzes a group of random numbers. Here is how it works:
The user is prompted to enter 3 positive integers: How many random numbers, lower bound and upper bound.
Upon receiving valid inputs, your program calls the function in A) to get all the random numbers accordingly and displays them. It then calls the function in B ) and finds the smallest element and its position.
If any of the user inputs is not valid, your program should display a warning message and allow re-entering until a valid value is entered.
The output of your program could look this:
How many random numbers are there, please? 6
What is the lower bound? 10
What is the upper bound? 90
The random numbers are:
\table[[Position#,Number],[1,56],[2,72],[3,12],[4,90],[5,63],[6,31]]
The smallest among them is: 12 at Position# 3.
A ) ( 1 5 Points ) Define a function int [ ]

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 Programming Questions!