Ask Question
17 February, 15:31

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.

+1
Answers (1)
  1. 17 February, 16:40
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers