Implement a class for Task 1 and Hardcode algorithms for Linear Search, Middle Value, First Value, Last Value, Highest Value, Lowest Value, and Bubble Sort. Main Function: Read random 1000 random intergers from a .txt file. Class will contain the methods below and an array as the data structure. Please use comments to identify constructors and methods in the program.

Respuesta :

Answer:

Code explained below

Explanation:

#include<fstream>//header file for file stream

using namespace std;

//your just need to add this function and

//call it after the declaration of array it will

//load the from the file into your array

//Function to read data from the file.

void readDataFromFile(int arr[], int size){

   fstream fin;//creating a file stream object.

   //opening the file in reading mode(fstream::in is for read mode).

   fin.open("file_name.txt",fstream :: in);

   //loop to store the data from the file to the array.

   for(int i = 0; i < size; i++){

       //we can use fin to load the data from file to array  

       //just like cin loads data from console into variables.

       fin >> arr[i];

   }

}

//program to read data from the .txt file

int main(){

   //array of size 1000

   const int size = 1000;

   int arr[size];

   //read data from the file

   readDataFromFile(arr,size);

   

}

ACCESS MORE