#include<iostream>
#include<fstream>
#include<vector>
int main()
{
char filename[20];
vector<int> vec;
vector<int> vec2;
int total=0;
cout << "Enter file name with extension ";
cin >> filename;
std::ifstream myfile(filename);
std::ofstream outfile("output.txt");
int a,i;
do
{
myfile >> a;
vec.push_back(a);
} while(!myfile.eof());
cout << "Writing original vector to file \n";
outfile << "Original Vector\n";
for(i = 0; i < vec.size(); i++){
cout <<i;
cout << "value of vec [" << i << "] = " <<
vec[i] << endl;
outfile << vec[i]<<"\n";
}
for( i = 0; i < vec.size(); i++){
vec2.push_back(vec[i]*10);
}
cout << "Writing 10x vector to file \n";
outfile << "10x Vector\n";
for( i = 0; i < vec2.size(); i++){
cout << "value of vec [" << i << "] = " <<
vec2[i] << endl;
total=total+vec2[i];
outfile << vec2[i]<<"\n";
}
outfile <<"\nTotal of 10x vector is
"<<total<<"\n";
}
C++ Write a program based on 8_lb that reads in the integer data from "input.txt" into...
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
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
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.
Description: Create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the name of file, sum of numbers, count of numbers, average of numbers, maximum value, minimum value, and range of values. Purpose: The purpose of this challenge is to provide experience working with numerical data in a file and generating summary information. Requirements: Create a program called numstat.py that reads a series of integer numbers from a file and determines...
Write a program that reads an integer k from user and finds the number of elements that are divisible by k in the file assignment4.txt. A number n is divisible by k if n = kx for some integer x > 0. You can use the mod operator % to test for divisibility. The file assign4.txt has integer values in the range [0,100 ]. You should use end-of-file controlled loop for this problem. Sample execution is given below. Assume the...
Write a C Program that: - Creates an input file (input.txt) - Take user inputted integer for number of lines in the input file - accepts inputted text from command line to the input file (input.txt) - saves and closes file. (input.txt) - reopens and displays the newly inputted contents of the file
Write a program that opens a text file called input.txt and reads its contents into a stack of characters. The program should then pop the characters from the stack and save them in a second text file called output.txt. The order of the characters saved in the second file should be the reverse of their order in the first file. We don’t know the text file length. Input.txt This is a file is for test output.txt tset rof si elif...
Exercise 4 Data rotation Write a program in C that reads from a file INFILE (you should create this file) a sequence of integer numbers. Consider that the length of the sequence is not knoun. Then, print to the file OUTFILE the sequence according to the following example: INFILE: 123456789 OUTFILE: 19 2 837465 The INFILE must be read only once!
(statistics.py) Write a program that reads data from the file provided, data.txt, into a list. Once the data are in a list, calculate and print the following: sum = 69.28 mean = 3.46 min = 0.19 max = 8.29 You may use the Python built-ins, min(), max(), and sum(). Format the numbers using '.2f'.
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...