Question 1
Back to Exercise
The program below does not compile. Which statement correctly describes the problem?
#include <iostream>
int main() {
int n;
std::cin << n;
std::cout << n * 2 << '\n';
return 0;
}
- A n must be initialised
- B cin is an input stream and uses the extraction operator >>; << is only defined for output streams Correct
- C cout cannot multiply
- D cin needs parentheses
Correct Answer: Option B
Remember the arrows point where the data goes: cin >> n moves data into n, cout << n moves it out to the screen.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!