// This program prompts the user for input and output file names. The input file // contains an unknown number of sets of 2 integers. For each set of integers, the sum // and product is calculated and the result output, in equation form, to the output file. #include #include using namespace std; int main() { char filename[40]; int x, y; ifstream fin; ofstream fout; cout << "Input file name: " ; cin >> filename; fin.open(filename); if (!fin) { cout << endl << "Could not open input file" << endl; return 1; } cout << endl << "Output file name: " ; cin >> filename; fout.open(filename); if (!fout) { cout << endl << "Could not open output file" << endl; return 1; } while (fin >> x >> y) { fout << x << " + " << y << " = " << x + y; fout << x << " * " << y << " = " << x * y << endl; } fin.close(); fout.close(); return 0; }