1. ## Another Homework Question

I have a homework problem that I am not sure about. It deals with how input is read. The problem is:

If input data are entered as follows
10 20
30 40
50 60
70 80

and the input statements that read it are

cin >> a >> b >> c;
cin >> d >> e >> f;
cin >> a >> b;

What are the contents of the variables a,b,c,d,e, and f after the statements have executed.

a=10
b=20
c=30
d=40
e=50
f=60
a=10
b=20

But what I don't understand is when will the values 70 and 80 be read? would there have to be an "g" and "h"?

Thanks,

Trekkie

2. You can modify a variable after the first time you set its value, so it's possible for a variable's value to change. Just follow the code step by step, updating the values of a-f each time something changes. When you are done going through the code, you'll have the answer.

3. The operator>>() is defined to read numbers sequentially. After it reads in a number, it marks where it stopped reading. If you use the operator>>() again, it begins where it left off.

If you do this:
Code:
int num = 10;
num = 20;
What does num equal?

Using the code:
Code:
cin>>some_variable_name;
is just like assigning a value to the variable: you are directing Mr. C++ to read in a value from the keyboard(cin) and store it in the variable.

4. Well what does the word variable mean: it means change. So theres no reason why a and b change change again. Also try compiling that code and put cout<< a etc afta each cin to what the variables hold.