Question: Please answer the following questions in beginner c++ code. The addition of comments are preferred The purpose of this lab is to review working with
The purpose of this lab is to review working with files, functions (reference and value), and arrays Write four functions to perfom the following tasks ReadData: this function opens a file "arrays.txt" and reads its contents into 3 integer arrays named A, B and C. Each aray holds 10 integers. The input file contains 3 lines each line holds 10 integer values. So the data in the first line is used to initialize array A. The data in the second line is used to initialize array B. And the data in the third line is used to initialize array C a. You may assume that "arrays.txt" has the following integers values: 097 5444321 0 1 3 45678910 0 2 3 45710 11 12 15 b. PrintArray: this function prints the elements of an aray of any size c. Reversed rrays this function reverses an array of any sizeplace. d. LongestSequence: this function finds and returns the length of the longest consecutive sequence of numbers in an array of any size. You may assume that the array is sorted in ascending order. For example. Longest sequence of (1,2,3,4.4,4,5,7,9,10 is 5. Note that repeated numbers ina sequence are skipped Longest sequence of 0,1,3,4,5,6,7,8,9,10 is 8. Longest sequence of t0,2,3,4,5,7,10,11,12,15) is 4. Write a main program that: Declares 3 arrays A, B, and C Calls the function readData to initialize these arrays Calls the function reverse.Array and send A as an argument Calls the function longestSequence three times to find and return the longest Calls the function printArray three times to print the elements of arrays A, B, and Calls the function printArray to print the elements of array A sequence in all three arrays. The results should be printed in main NOTE: Any parameter that is not supposed to be changed inside a function must be declared as a constant parameter
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
