This is a C programming question.
We have a file containing floating point numbers (we don't know how many). Write a complete C program that alternately averages only the floating point numbers (for example 3.50, 12.507, 123.60,5.98 would lead to the result (12.507+5.98)/2), ignore the whole numbers. Use file input, assuming the file is named "numbers.data". The program should be compatible with files that contain several numbers on separate lines.
#include <stdio.h>
int main() {
FILE *fp = fopen("numbers.data", "r");
if (fp) {
double total = 0, count = 0, n1, n2;
while (fscanf(fp, "%lf", &n1) != EOF && fscanf(fp, "%lf", &n2) != EOF) {
total += n2;
++count;
}
printf("Average of alternate numbers is %lf\n", total/count);
fclose(fp);
} else {
printf("numbers.data does not exists\n");
}
return 0;
}
This is a C programming question. We have a file containing floating point numbers (we don't...
write a program that will read a file containing floating point numbers, store the numbers into an array, count how many numbers were in the file, then output the numbers in reverse order. Your program should only use one array and that array should not be changed after the numbers have been read. You should assume that the file does not contain more than 100 floating point numbers. Numbers found in file 100.7362 105.2896 66.3493 105.6688 91.6180 64.8770 73.9249 87.3441...
Write a PYTHON program that reads a file (prompt user for the input file name) containing two columns of floating-point numbers (Use split). Print the average of each column. Use the following data forthe input file: 1 0.5 2 0.5 3 0.5 4 0.5 The output should be: The averages are 2.50 and 0.5. a) Your code with comments b) A screenshot of the execution Version 3.7.2
In this Assignment assume that you have a text file with numbers separated by newlines. you want to read the numbers in and add them up. since we want to be flexible on the type and size of numbers we can handle, we will use double floating point. Text file contains following numbers 8 3 6.5 9 0 assume that the files are well-formed: it will contain only valid numbers separated by newlines. Using C language
In C++ Exercise #2: Design and implement a programming (name it SimpleMath) that reads two floating-point numbers (say R and T) and prints out their values, sum, difference, and product on separate lines with proper labels. Comment your code properly and format the outputs following these sample runs.
Language: c++ Write a program that opens a file to read 20 floating point numbers and store the information in a 4 x 5 array. The program should do the following: a. Compute the average of each set of 5 values b. Determine the largest value of the 20 values c. Report the results; print the original matrix and average of each row, and the largest of the values in this function. d. At the end of the program prompt...
Write c program. Do part 4 and 5
CH-12 TEXT FILES SE 12-3 Create a text file named grade.txt that you type yourself by your Each record in grade.txt should have the following format: by Columns 1-4 6-8 number of a student A grade out of 100 EYERCISE 12-4 Write a program that will read the identification numbers of students and their letter grades (A, B, C, D, or F) from the keyboard and store them in a text file...
Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...
Please don't use a void fuction and this is a c++ question.
Thanks
Write a program that reads two input files whose lines are ordered by a key data field. Your program should merge these two files, writing an output file that contains all lines from both files ordered by the same key field. As an example, if two input files contain student names and grades for a particular class ordered by name, merge the information as shown below Using...
C++ please
Write a program that reads the following sentences from a file: I am Sam Sam I am That Sam I am That Sam I am I do not like that Sam I am Do you like green eggs and ham I do not like them But I do like spam! You will first have to create the text file containing the input, separate from your program. Your program should produce two output files: (i) (ii) one with the...
C++ Programming Objects
Problem Assignment: Programming challenge #1 on page 714: "File Head Program" Write a program that asks the user for the name of a file. The program should display the first ten lines of the file on the screen (the “head" of the file). If the file has fewer than ten lines, the entire file should be displayed, with a message indicating the entire file has been displayed. Lab Help: Use the following two files to test your...