 # Summing Two Numbers from a File in Linux and Program should be in C...

## Question

Summing Two Numbers from a File in Linux and Program should be in C

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.

Description
It reads a file of numbers and sum of each pair. Each time it finds the sum it checks with the pre-defined number and prints appropriate message. A number is defined using a random number defined at the start of the program. It finds the time taken to read and process the data with different size of data file.

Input:
1. Data file name, to be specified in the program.
2. Pre-defined number is generated randomly.

For input file, we have generated 6 data files of various size by generating random numbers.
Each file is saved. This is achieved using the following code:

FILE *f;
f = fopen("numbers5.dat", "w");
char str;
for(int i = 0; i< 120000; i++) {
sprintf(str, "%d", rand() % 10000);...

By purchasing this solution you'll be able to access the following files:
Solution.docx.

# 50% discount

Hours
Minutes
Seconds
\$10.00 \$5.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 C-Family Programming 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.