Write a program: 1. Ask the user for names of the two input files and a name of
ID: 3656287 • Letter: W
Question
Write a program: 1. Ask the user for names of the two input files and a name of an output file. The two input files contain integers in any order. Each input file contains no more than 20 integers. 2. Create two arrays of integer of size 20. One for each input file. #. Read in the numbers from the input files inot the arrays respectively. 4. Find the smallest and the largest numbers from the two input files and write the answers into a third file - the output file. 5. Find the average of all numbers and write to the third file (output file)Explanation / Answer
#include "std_lib_facilities_3.h" int main() { //Input 1 cout > name; ifstream ist1(name.c_str()); if (!ist1) error("Can't open input file: ",name); //Input 2 cout > name2; ifstream ist2(name2.c_str()); if (!ist2) error("Can't open input file name: ",name2); //Output cout > oname; ofstream ost(oname.c_str()); if (!ost) error("Can't open output file: ",oname); string s, t; int i = 1; int flag = 1; while(true) { if (!getline(ist1, s)) {flag = 1; break;} if (!getline(ist2, t)) {flag = 2; break;} ostRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.