Determine by hand the output of each program listed on the following pages using
ID: 652101 • Letter: D
Question
Determine by hand the output of each program listed on the following pages using the data files shown below.
Contents of data file:
2.0 3
4.0 5
6.0 7
Program:
#include <iostream>
#include <fstream>
using namespace std;
int main ( void )
{
double x,y,z;
ifstream infile("E:dat1.in");
infile >> x >> y >> z;
cout << "x = " << x << endl << "y = " << y << endl
<< "z = " << z << endl;
infile.close()
return 0; }
X = ?
Y = ?
Z = ?
Explanation / Answer
infile >> x >> y >> z; reads the first 3 numbers of the file and store in variables x,y,z
first 3 numbers in file are 2.0,3,4.0
so output would be
X = 2
Y = 3
Z = 4
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.