Which of the following statements is/are correct? 1. It is not possible to…
2023
Which of the following statements is/are correct? 1. It is not possible to combine two or more files opening mode in open() method. 2. It is possible to combine two or more files opening mode in open() method 3. ios::in and ios::out are input and output file opening modes respectively.
- A.
1,3
- B.
2,3
- C.
3 only
- D.
More than one of the above
- E.
None of the above
Attempted by 113 students.
Show answer & explanation
Correct answer: B
Step 1: In C++, the open() method allows combining multiple file opening modes using the bitwise OR operator (|). For example, open("file.txt", ios::in | ios::out) opens a file for both reading and writing. Step 2: Statement 1 claims that combining modes is not possible, which is incorrect. Therefore, statement 1 is false. Step 3: Statement 2 correctly states that combining modes is possible, so it is true. Step 4: Statement 3 is correct because ios::in is used for input (reading) and ios::out is used for output (writing). Step 5: Since statements 2 and 3 are correct, the correct option must include both.