C++ Self-Exercises. HELP

I don't get this exercises. Maybe you do! HERE!

1)What, if anything, prints when each of the following C++ statements is performed? If nothing prints, then answer "nothing". Assume x = 2 and y = 3.
a) cout << x;
b) cout << x + x;
c) cout << "x=";
d) cout << "x = " << x;
e) cout << x + y << " = " << y + x;
f) z = x + y;
g) cin >> x >> y;
h) // cout << "x + y = " << x + y"
i) cout << "\n";

EDIT:
2) Which of the following C++ statements contain variables whose values are replaced?
a) cin >> b >> c >> d >> e >> f;
b) p = i + j + k + 7;
c) cout << "variables whose values are destroyed";
d) cout << "a = 5";

Last edited on
1)
a)2
b)4
c)x=
d)x=2
e)5=5
f)nothing
g)nothing
h)nothing
i)It prints nothing but causes the line to end.

I do not understand your second question.
1)
a)2
b)4
c)x=
d)x=2
e)5=5
f)nothing
g)nothing
h)nothing
i)It prints nothing but causes the line to end.

I do not understand your second question.


Wow.....That really helped.... >.>

EDIT: Giving my the answers doesn't help me.... I need work!!! Explaination!
Last edited on
Don't give the person the answers! :)

a) Should print the value of x. We know what x is, so what do you think it should print?

b) Should print the value of x+x. And we know what this is.

c) This prints the word/words/wordy-thing "x=".

d) This prints the word/words/wordy-thing "x = " and then the value of x. And what's x?

e) You should be getting the hang of this by now. cout << firstthing << secondthing << etc prints firstthing, then secondthing, then etc.

f) Does setting variables to other expressions print anything to the screen?

g) This lets the user enter their value for x followed by a space, tab, enter, or any combination of those, and then their value for y. Does this print anything?

h) Think about what the purpose of a comment is.

i) \n is basically what you type instead of an enter in strings in C++ (and C and Java and C# and Ruby and Objective C and Python and Perl and Smalltalk(?) and ...)
Topic archived. No new replies allowed.