Question: the program is for c langauge . the RandomData.txt = 9, 2, 11, 5, 3, 15, 23 or any randndom numbers Problem Statement Given a

 the program is for c langauge . the RandomData.txt = 9,

the program is for c langauge .

the RandomData.txt = 9, 2, 11, 5, 3, 15, 23 or any randndom numbers

Problem Statement Given a text file "RandomData.txt", that contains random integer numbers. You are required to write a program that does the following: 1. Read the content of the file and store the numbers in an integer array 2. Print the index of the nth smallest element of the array Here is an example to illustrate the requirements. If the input file contains the numbers: 9, 2, 11, 5, 3, 15, 23 and 12, which after sorting become: 2, 3, 5, 9, 11, 12, 15, 23, and if the user wants to find the index of the 4th minimum element in the original data, the program should print "O" as a result, since the 0th element (9) in the original array is the 4th minimum element in the sorted array. In other words, element 9 of the array is the 4h minimum element and is at position 0 in the original array (or in the file) To simplify the requirements, let us assume that the number of elements in the file does not exceed 100 elements m Requirements Your program should mainly consist of functions, and the main function contains function calls only. It should start by reading the fle "RandomData.txt", and check for its existence. If the opening of the file fails, such as the file does not exist, the code should exit with an appropriate message. If opening succeeds, the code should proceed with the following functions. 1- Read from file This function (ReadFile) receives as input the file pointer, reads and saves the elements in an integer array, and returns this array. The function should also return the number of elements read from the file. 2- Read minimum rank from the user This function (ReadRank) reads the rank of the minimum from the user. The function should check for the entered rank to be within limits of the size of the array and return a valid rank value. If the user enters 0 or a negative value, then this will be the value to stop the program, should return 0. Upon return to the main program, the program should print the message "END! as shown below, and stop the execution. and the functiorn 3- Find minimum with given rank: This function (FindMinimum) is given the data array and the rank of the minimum to find as inputs It should return the index of the minimum with the given rank On return from the previous function called, the code should display in the main loop: the value of the given index. Notes 1 To keep track of the positions of the elements of the array, you need a two dimensional array, with 2- For the function to find the minimum with given rank, you will need to sort the input array. You may 3- The rank of the minimum assumes the array elements indexed from 1 to size of array. Your array is 4- Not to alter the initial array, when calling the function to find the minimum with given rank (step 3 the first column containing the indices and the second column containing the array elements need either the selection sort algorithm from your lectures, or the bubble sort. Also, for that purpose you will need a swap function. indexed from 0 to size -1 above), you need to copy the original array into a temporary one and process the temporary array, thus keeping the original one unchanged. This should be implemented as a function with the two arrays (original and copy) as arguments. 5- You will also need a function to display the array (DisplayArray), as this is needed to check your results. Problem Statement Given a text file "RandomData.txt", that contains random integer numbers. You are required to write a program that does the following: 1. Read the content of the file and store the numbers in an integer array 2. Print the index of the nth smallest element of the array Here is an example to illustrate the requirements. If the input file contains the numbers: 9, 2, 11, 5, 3, 15, 23 and 12, which after sorting become: 2, 3, 5, 9, 11, 12, 15, 23, and if the user wants to find the index of the 4th minimum element in the original data, the program should print "O" as a result, since the 0th element (9) in the original array is the 4th minimum element in the sorted array. In other words, element 9 of the array is the 4h minimum element and is at position 0 in the original array (or in the file) To simplify the requirements, let us assume that the number of elements in the file does not exceed 100 elements m Requirements Your program should mainly consist of functions, and the main function contains function calls only. It should start by reading the fle "RandomData.txt", and check for its existence. If the opening of the file fails, such as the file does not exist, the code should exit with an appropriate message. If opening succeeds, the code should proceed with the following functions. 1- Read from file This function (ReadFile) receives as input the file pointer, reads and saves the elements in an integer array, and returns this array. The function should also return the number of elements read from the file. 2- Read minimum rank from the user This function (ReadRank) reads the rank of the minimum from the user. The function should check for the entered rank to be within limits of the size of the array and return a valid rank value. If the user enters 0 or a negative value, then this will be the value to stop the program, should return 0. Upon return to the main program, the program should print the message "END! as shown below, and stop the execution. and the functiorn 3- Find minimum with given rank: This function (FindMinimum) is given the data array and the rank of the minimum to find as inputs It should return the index of the minimum with the given rank On return from the previous function called, the code should display in the main loop: the value of the given index. Notes 1 To keep track of the positions of the elements of the array, you need a two dimensional array, with 2- For the function to find the minimum with given rank, you will need to sort the input array. You may 3- The rank of the minimum assumes the array elements indexed from 1 to size of array. Your array is 4- Not to alter the initial array, when calling the function to find the minimum with given rank (step 3 the first column containing the indices and the second column containing the array elements need either the selection sort algorithm from your lectures, or the bubble sort. Also, for that purpose you will need a swap function. indexed from 0 to size -1 above), you need to copy the original array into a temporary one and process the temporary array, thus keeping the original one unchanged. This should be implemented as a function with the two arrays (original and copy) as arguments. 5- You will also need a function to display the array (DisplayArray), as this is needed to check your results

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!