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";
Solution:
a) 2
b) 4
c) x=
d) x= 2
e)5 = 5
f) nothing
g) nothing
h) nothing
i) nothing. new line
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";
Solution:
a) 2
b) 4
c) x=
d) x= 2
e)5 = 5
f) nothing
g) nothing
h) nothing
i) nothing. new line
Post A Comment:
0 comments: