1. use c++
write a c++ program that reads 10 integers from a file named input.txt in this file the 10 integers wil be on a single line with space between the. calculate the average of these numbers and then write his number to a file named output.txt. if the program is unable to successfully complete the file operations then display eero message to the console.
#include <iostream> #include <fstream> #include <string> using namespace std; int main() { ifstream in("input.txt"); if (in.is_open()) { // open file double total = 0, count = 0; // initialize total and count to 0 double num; while (in >> num) { // read numbers from file total += num; // add number to total ++count; // increase count by 1 } ofstream out("output.txt"); out << total / count << endl; // print average to output file in.close(); // close input file out.close(); // close output file } else { cout << "input.txt does not exists!" << endl; } return 0; }
1. use c++ write a c++ program that reads 10 integers from a file named input.txt...
Write a C program that reads a list of positive integers from a file named "input.txt." and count number of odd integers and even integers and prints the results to another file called "results.txt". Please submit both the input and results files along with the c program.
Write a program that reads a file named input.txt and writes a file that contains the same contents, but is named output.txt. The input file will contain more than one line when I test this. Do not use a path name when opening these files. This means the files should be located in the top level folder of the project. Do not use a copy method that is supplied by Java. Your program must read the file line by line...
write a program in c ++ that reads the length and width of a rectangle from a file named input.txt and write the area and perimeter of the rectactangle to file named output.txt
C++
Write a program based on 8_lb that reads in the integer data from "input.txt" into a vector. Please prompt for the file name and append the "txt". Then create another vector where each element is the original vector times 10. Create a variable total and sum up the numbers from the second vector. The total should be 17510. Then write the data from the original vector and the 10 times vector to a file. See output.txt for the format....
How to write a Java program that reads the file "input.txt" and writes all even values from this file into a new file called "output.txt." Sample input 10 12 1 3 5 34 2 5 7 9 44
C++
3. Write a program that reads integers from a file, sums the values and calculates the average. a. Write a value-returning function that opens an input file named in File txt. You may "hard-code" the file name, i.e., you do not need to ask the user for the file name. The function should check the file state of the input file and return a value indicating success or failure. Main should check the returned value and if the file...
Task 1 : Write a Java program that prompts for and reads 10 integers from the user into an integer array of size 10, it then: - calculates the sum and average of positive numbers of the array and displays them. [Note: consider 0 as positive] Note: The program must display the message: "There are no positive values" if the array does not contain any positive value.
C++ Programming question
Problem: 5. Write a program that reads in a list of integers into an array with base type int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input, the program should request a file name. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is to be...
write a short c++ program that reads integers from a file named zzin1.dat (5,7,21,2,-9,10,3,1,11) until the eof condition is reached add 1 to each value and save it to an output file named acdc1.dat
Write a program in C that reads 20 float numbers from a file. The values are stored in a vector (1-dimensional array). Find and display the smallest number, the second smallest number, and the third smallest number of the set. Use only these libraries: stdio.h, stdlib.h, math.h, and string.h. Below is an example of the input file (in1.txt) and the resulting output file (output.txt). In1.txt: 3.14 4.05 -3.73 4.13 1.32 -2.21 0.46 4.57 4.64 -3.42 4.57 -0.14 3.00 -3.58 -0.78...