#include "iostream"#include "fstream"#include "cstdlib"usingnamespacestd;
int main(int argc, charconst *argv[])
{
char In_File_Name[16],Out_File_Name[16];
ifstream In_Stream;
ofstream Out_Stream;
cout << "I will sum three numbers taken from an input" << endl
<< "file and write the sum to an output file" << endl;
cout << "Enter the input file name(maximum of 15 characters):" << endl;
cin >> In_File_Name;
cout << "Enter the output file name(maximum of 15 characters):" << endl;
cin >> Out_File_Name;
cout << "I will read numbers from the file"
<< In_File_Name << " and" <<endl
<< "place the sum in the file "
<< Out_File_Name << endl;
In_Stream.open(In_File_Name);
if(In_Stream.fail())
{
cout << "Input file opening error!" << endl;
exit(1);
}
Out_Stream.open(Out_File_Name);
if(Out_Stream.fail())
{
cout << "Output file opening error!" << endl;
exit(1);
}
int first,second,third;
In_Stream >> first >> second >> third;
Out_Stream << "The sum of input is " << (first + second + third) << endl;
In_Stream.close();
Out_Stream.close();
cout << "Programme run successfully!" << endl;
return0;
}