250+ TOP MCQs on C++ Basics and Answers

C++ Programming Multiple Choice Questions & Answers (MCQs) on “Basics”.

1. Which of the following is the correct syntax of including a user defined header files in C++?
a) #include
b) #include
c) #include “userdefined”
d) #include [userdefined]
Answer: c
Clarification: C++ uses double quotes to include a user-defined header file. The correct syntax of including user-defined is #include “userdefinedname”.

2. Which of the following is a correct identifier in C++?
a) 7var_name
b) 7VARNAME
c) VAR_1234
d) $var_name
Answer: c
Clarification: The rules for writing an identifier is as follows:
i) may contain lowercase/uppercase letters, digits or underscore(_) only
ii) should start with a non-digit character
iii) should not contain any special characters like @, $, etc.

3. Which of the following is called address operator?
a) *
b) &
c) _
d) %
Answer: b
Clarification: & operator is called address operator and is used to access the address of a variable.

4. Which of the following is used for comments in C++?
a) // comment
b) /* comment */
c) both // comment or /* comment */
d) // comment */
Answer: c
Clarification: Both the ways are used for commenting in C++ programming. // is used for single line comments and /* … */ is used for multiple line comments.

5. What are the actual parameters in C++?
a) Parameters with which functions are called
b) Parameters which are used in the definition of a function
c) Variables other than passed parameters in a function
d) Variables that are never used in the function

Answer: a
Clarification: Actual parameters are those using which a function call is made i.e. which are actually passed in a function when that function is called.

6. What are the formal parameters in C++?
a) Parameters with which functions are called
b) Parameters which are used in the definition of the function
c) Variables other than passed parameters in a function
d) Variables that are never used in the function
Answer: b
Clarification: Formal parameters are those which are used in the definition of a function. They are the parameters that represent the actual parameters passed and they are the one which is used inside the function.

7. Which function is used to read a single character from the console in C++?
a) cin.get(ch)
b) getline(ch)
c) read(ch)
d) scanf(ch)
Answer: a
Clarification: C++ provides cin.get() function to read a single character from console whereas others are used to read either a single or multiple characters.

8. Which function is used to write a single character to console in C++?
a) cout.put(ch)
b) cout.putline(ch)
c) write(ch)
d) printf(ch)
Answer: a
Clarification: C++ provides cout.put() function to write a single character to console whereas others are used to write either a single or multiple characters.

9. What are the escape sequences?
a) Set of characters that convey special meaning in a program
b) Set of characters that whose use are avoided in C++ programs
c) Set of characters that are used in the name of the main function of the program
d) Set of characters that are avoided in cout statements

Answer: a
Clarification: Escape sequence is a set of characters that convey a special meaning to the program. They are used to convey a meaning which cannot be conveyed directly.

10. Which of the following escape sequence represents carriage return?
a) r
b) n
c) nr
d) c
Answer: a
Clarification: r is used to represent carriage return which means move the cursor to the beginning of the next line.

11. Which of the following escape sequence represents tab?
a) t
b) tr
c) b
d) a
Answer: a
Clarification: t is used to represent tab which means a set of blank spaces in a line.

12. Who created C++?
a) Bjarne Stroustrup
b) Dennis Ritchie
c) Ken Thompson
d) Brian Kernighan
Answer: a
Clarification: Bjarne Stroustrup is the original creator of C++ during 1979 at AT&T Bell Labs.

13. Which of the following is called insertion/put to operator?
a) <<
b) >>
c) >
d) <
Answer: a
Clarification: << operator is called insertion or put to operator i.e. insert/put things to console/files.

14. Which of the following is called extraction/get from operator?
a) <<
b) >>
c) >
d) <
Answer: b
Clarification: >> operator is called extraction or get from operator i.e. extract/get things from console/files.

15. A language which has the capability to generate new data types are called ________________
a) Extensible
b) Overloaded
c) Encapsulated
d) Reprehensible
Answer: a
Clarification: Languages that can produce/generate new data types are called extensible languages as they have the ability to handle new data types.

  250+ TOP MCQs on Resource Management and Answers

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top