# Project description: Take a file of numbers and sum the first numbe...

## Question

Project description: Take a file of numbers and sum the first number with the second, then the first with the third, the first with the forth, and so on. Then sum the second with the third, the second with the forth, and so on. Use random numbers and print a message if the sum you get meets some pre-determined value (you choose the value, in class we said 0 but you could use any value). This program will require    a nested loop. For example, given the file consists of numbers 1, 3, 5, -3, and 6, you should compute the following:

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.

# 50% discount

Hours
Minutes
Seconds
\$70.00 \$35.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Operating Systems Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.