Question: #ifndef FillUp_h #define FillUp_h // A simple function that fills in an array with numbers // corresponding to the indices void fillUp(int someList[], int size){
#ifndef FillUp_h #define FillUp_h // A simple function that fills in an array with numbers // corresponding to the indices void fillUp(int someList[], int size){ for (int i = 0; i < size; i++) { someList[i] = i; } } // A function to print out the array, one element per line void print(int someList[], int size){ for (int i = 0; i < size; i++) { std::cout << someList[i] << std::endl; } } // A function to print the value of a specific array position void printPos(int someList[], int pos){ std::cout << someList[pos] << std::endl; } #endif /* FillUp_h */
Big arrays code starts here:::
#include #include "FillUp.h" using namespace std; int main(int argc, const char * argv[]) { // Read in the size from the user int size; cin >> size; // Create an array of appropriate size int arr[size]; // Call the fillUp function fillUp(arr, size); // Call the printPos function on last position printPos(arr, size-1); return 0; } The program reads in an integer from the user and creates an array of that many elements. It then call the fillUp function found in FillUp.h, which populates each cell of the array with an integer value corresponding to the index. The code then calls the printPos function which prints out the value of the last element of the array.
The code works correctly for small array sizes. Your task is to make it work for array sizes of more than 10 million elements. You should not modify the FillUp.h file, because you will not be uploading that file.
Modify the bigArrays.cpp file to meet the requirements above, and upload it for evaluation. It must use the fillUp function to get populated, and the printPos function to produce the output.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
