Question
1
3 1 + 3 = 4
5 1 + 5 = 6 3 + 5 = 8
−3 1 + (−3) = −2 3 + (−3) = 0 5 + (−3) = 2
6 1 + 6 = 7 3 + 6 = 9 5 + 6 = 11 (−3) + 6 = 3
However you should use larger files of numbers, since small files of numbers will be processed in almost to zero time.
Using the clock( ) function in Linux: After your program runs, use the clock( ) function, as we discussed in class, to compute the length of time it takes your program to run. Note the time and then increase or decrease the size of your file of numbers. Note those times also. You should run it for different sizes (at least three) of files and note the different times. You have an example program on BB on how to use the clock( ) function.
Written description: Write up a description of your program, how it works, what data structures you used, what are the input requirements, what are the output requirements, everything should be explained.
Written results: Write an explanation of your program runs (your results). Explain the results (how long did it take for your program to run with different size files of numbers). You can set up a table and/or a graph to illustrate your results.
Solution Preview
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.
int main(int argc, char** argv){
/* Variable to hold the file path which is given by the user */
std::string filePath;
/* Display user friendly messages to provide path to file of numbers */
std::cout << "Default "<< dDEFAULT_FILE_PATH <<" file path selected" << std::endl;
std::cout << "Please enter file path or press enter to continue with " << dDEFAULT_FILE_PATH << " : " << std::endl;
/* Read file path from user */
std::getline(std::cin, filePath);
/* If file path entry was skipped by user, default to dDEFAULT_FILE_PATH */
if(filePath.empty())
{
filePath = dDEFAULT_FILE_PATH;
}
/* Display the selected file name */
std::cout << "*************************************************************************" << std::endl;
std::cout << "\tSelected file is : " << filePath << std::endl;
std::cout << "*************************************************************************" << std::endl;
/* Open the user input file in read mode */
FILE* numbersFile = fopen(filePath.c_str(), "r");
/* Check if we were able to successfully open the specified file */
if(numbersFile)
{...
By purchasing this solution you'll be able to access the following files:
Solution.zip.