Explore topic-wise MCQs in C++ Programming.

This section includes 14 Mcqs, each offering curated multiple-choice questions to sharpen your C++ Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

Which of the following is used to move the file pointer to start of a file?

A. ios::beg
B. ios::start
C. ios::cur
D. ios::first
Answer» B. ios::start
2.

Which function is used to reposition the file pointer?

A. moveg()
B. seekg()
C. changep()
D. go_p()
Answer» C. changep()
3.

Which function is used in C++ to get the current position of file pointer in a file?

A. tell_p()
B. get_pos()
C. get_p()
D. tell_pos()
Answer» B. get_pos()
4.

Which of the following is the default mode of the opening using the fstream class?

A. ios::in
B. ios::out
C. ios::in|ios::out
D. ios::trunc
Answer» D. ios::trunc
5.

Which of the following is the default mode of the opening using the ifstream class?

A. ios::in
B. ios::out
C. ios::app
D. ios::trunc
Answer» B. ios::out
6.

Which of the following is not used to seek file pointer?

A. ios::set
B. ios::end
C. ios::cur
D. ios::beg
Answer» B. ios::end
7.

What is the return type open() method?

A. int
B. char
C. bool
D. float
Answer» D. float
8.

Which of the following is the default mode of the opening using the ofstream class?

A. ios::in
B. ios::out
C. ios::app
D. ios::trunc
Answer» C. ios::app
9.

What is the use of ios::trunc mode?

A. To open a file in input mode
B. To open a file in output mode
C. To truncate an existing file to half
D. To truncate an existing file to zero
Answer» E.
10.

By default, all the files in C++ are opened in _________ mode.

A. Text
B. Binary
C. ISCII
D. VTC
Answer» B. Binary
11.

Which of the following is not used as a file opening mode?

A. ios::trunc
B. ios::binary
C. ios::in
D. ios::ate
Answer» B. ios::binary
12.

Which of the following is used to create a stream that performs both input and output operations?

A. ofstream
B. ifstream
C. iostream
D. fstream
Answer» E.
13.

Which of the following is used to create an output stream?

A. ofstream
B. ifstream
C. iostream
D. fsstream
Answer» B. ifstream
14.

Which header file is required to use file I/O operations?

A. <ifstream>
B. <ostream>
C. <fstream>
D. <iostream>
Answer» D. <iostream>