Ask Question
2 February, 20:25

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.

+2
Answers (1)
  1. 2 February, 23:01
    0
    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.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Given the availability of an ifstream object named indata and an ofstream object named outdata, write the other statements necessary to ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers