Computers and Technology

We are designing a program that must do the following: Read 3 integers from a file called "data. txt"
Sum the integers
Compute the mean of the integers
Output the mean to a file called "mean. txt".
We are required to select functions from the library provided below to complete our program. Inside of the main () function, fill in the correct C statements to satisfy the four requirements listed above. You must fill in all the lines labeled with "statement x", where x is 2, 3, 4, 5, or 6. The first statement has been completed for you.
// These are the library functions that we must invoke!
// Precondition: The input file must already be open.
int read_integer (FILE *infile)
{
int number = 0;
fscanf (infile, "%d", &number);
return number;
}

int calculate_sum (int number1, int number2, int number3)

{
int sum = 0;
sum = number1 + number2 + number3;
return sum;
}

double calculate_mean (int sum, int number)
{
double mean = 0.0;
mean = ((double) sum) / number;
return mean;
}
// Precondition: The input file must already be open.
void print_double (FILE *outfile, double number)
{
fprintf (outfile, "%0.2lf\n", number);
}
// Fill in the appropriate statements for main ().
#include
int main (void)
{
int n1 = 0, n2 = 0, n3 = 0, sum = 0;
double average = 0.0;
FILE *infile = NULL, *outfile = NULL;
// We will not check to see if files were opened successfully; assume they are
infile = fopen ("data. txt", "r");
outfile = fopen ("mean. txt", "w");
n1 = read_integer (infile) // statement 1
// statement 2 (2 pts)
// statement 3 (2
pts)
// statement 4 (2 pts)
// statement 5 (2 pts)
// statement 6 (2
pts)
fclose (infile);
fclose (outfile);
return 0;
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 05:10, ahoney2233
Suppose we have a byte addressable computer that has a 32-byte cache with 8 bytes per block. the memory address is 8 bits long. the system accesses memory addresses (in hex) in this exact order: 6e, b9, 17, e0, 4e, 4f, 50, 91, a8, ab, ad, 93, and 94. (a) assuming the cache is direct mapped, what memory addresses will be in cache block 2 after the last address has been accessed? (b) assuming the cache is direct mapped, what is the hit ratio for the entire memory reference sequence given, assuming the cache is initially empty? (c) assuming the cache is 2-way set associative with a lru replacement policy, what is the hit ratio?
Answers: 3
image
Computers and Technology, 22.06.2019 07:00, candiceforever123
Idon understand these and need some ! ?
Answers: 2
image
Computers and Technology, 23.06.2019 03:00, jarteria0
State 7 common key's for every keyboard
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, 19youngr
Which company provides a crowdsourcing platform for corporate research and development? a: mtruk b: wiki answers c: mediawiki d: innocentive
Answers: 2
Do you know the correct answer?
We are designing a program that must do the following: Read 3 integers from a file called "data. tx...

Questions in other subjects:

Konu
Mathematics, 03.06.2021 03:00