Question: Write a program that reads in a text file of numbers into an array. The numbers will be integers (both positive and negative).After reading the
Write a program that reads in a text file of numbers into an array. The numbers will be integers (both positive and negative).After reading the numbers into an array and printing the array, then find the minimum value in the array. You don't need to use any sorting algorithms for this; just keep track of the current minimum value within the loop. HINT: Start by setting the current minimum to the first element in the array. Then for each array element after the first one, compare with element's value the current minimum. If the element is smaller than the current minimum, then set the current minimum to that element's value. Otherwise, just continue. At the end of the loop, the current minimum will then be the minimum for the entire array. Requirements Although you don't need to read into an array to get the minimum, I want you to use one. Also, have the following three functions in your code (I want you to get more practice with functions): - readInFile- this takes the array and the count (pass this in as a reference). Then open a file called "numbers.txt" and read in the numbers. - printArray- this takes the array and the count and prints the numbers in the array. - getMin- this takes the array and the count, finds the minimum value and returns it. So this function should have intas a return type, not void. Do not use goto statements. You will get an automatic zero for your lab. EXAMPLE RUN (no user input) ================================================ Printing Numbers... 18 3 43 7 8 18 5 24 2 9 0 the minimum value is: 18 ===========================================
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
