Ask Question
30 July, 07:53

Suppose that infile is an ifstream variable and it is associated with the file that contains the following dа ta: 27306 savings 7503.35. Write the C11 statement (s) that reads and stores the first input in the int variable acctNumber, the second input in the string variable accountType, and the third input in the double variable balance.

+4
Answers (1)
  1. 30 July, 08:00
    0
    The C+ + code is given below. The highlighted code is essential for reading the file. Appropriate comments given guide for better understanding

    Explanation:

    / / reading a text file

    #include

    #include

    #include

    using namespace std;

    int main ()

    {

    int acctNumber;

    string accountType;

    double balance;

    / / openfile

    ifstream infile ("inputfile. txt");

    if (infile. is_open ())

    {

    while (true)

    {

    / / reading from file

    infile >> accountType;

    infile >> accountType;

    infile >> balance;

    / / break loop when end of file reached

    if (infile. eof ())

    break;

    }

    / / close file

    infile. close ();

    }

    else

    cout << "Unable to open file";

    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Suppose that infile is an ifstream variable and it is associated with the file that contains the following dа ta: 27306 savings ...” 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