Ask Question

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. 6 December, 12:50
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers