Given the availability of an ifstream object named indata and an ofstream object named outdata, write the other statements necessary to read one integer from a file called currentsales and write twice its value into a file called projectedsales. Assume that this is the extent of the input and output that this program will do.

Respuesta :

Limosa

Answer:

The following program:

int value;    //set an integer vaiable

indata.open("currentsales");

outdata.open("projectedsales");

//read one integer from the file "currentsales".

indata  >> value;

//write twice of its value into the file "projectedsales".  

outdata << (value*2);

indata.close();

outdata.close();

Explanation:

Here, we define an integer variable "value".

Then, we use open() method with indata and outdata for "currentsales" and "projectsales".

Then, we read one integer from the file "currentsales".

Then, we write twice of its value into the file "projectedsales".  

Then, we close both open() method which we open previously by using close() method.

ACCESS MORE