The following program is supposed to read the length and width of a rectangle from a file named input.txt and write the area and perimeter of the numbers to a file named output.txt. However, it fails to do so. Rewrite the program so that it accomplishes what it is intended to do. (Also, include statements to close the files.) (10)
include
using namespace std;
int main()
double length, width;
ofstream outfile;
infile.open(“input.txt”);
infile >> length >> width;
outfile
return 0;
“area=”
<< ” ,=”” perimeter=””>
return 0;
}
>