Important MCQ

Which statement reads a whole line into a string s?

Q.Which statement reads a whole line into a string s?

A) cin >> s;
B) getline(cin, s);
C) cout << s;
D) s = cin;
Correct Answer:
Option B
Detailed Explanation:
B) getline(cin, s); is correct. Apply the relevant C++ rules: integer versus floating-point division, remainder, operator precedence, loop execution, ternary selection, data types, and the syntax of main().