1. Which of the following is the correct syntax of including a user defined header files in C++?
A. #include <userdefined.h>
B. #include <userdefined>
C. #include “userdefined”
D. #include [userdefined]
Explanation:
C++ uses double quotes to include a user-defined header file. The correct syntax of including user-defined is #include “userdefinedname”.
2. A language which has the capability to generate new data types are called
A. Extensible
B. Overloaded
C. Encapsulated
D. Reprehensible
Explanation:
Languages that can produce/generate new data types are called extensible languages as they have the ability to handle new data types.
3. Which of the following is a correct identifier in C++?
A. 7var_name
B. 7VARNAME
C. VAR_1234
D. $var_name
Explanation:
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.
4. Which of the following is called extraction/get from operator?
A. <<
B. >>
C. >
D. <
Explanation:
>> operator is called extraction or get from operator i.e. extract/get things from console/files.
5. Which of the following is called address operator?
A. *
B. &
C. _
D. %
Explanation:
& operator is called address operator and is used to access the address of a variable.
6. Which of the following is called insertion/put to operator?
A. <<
B. >>
C. >
D. <
Explanation:
<< operator is called insertion or put to operator i.e. insert/put things to console/files.
7. Which of the following is used for comments in C++?
A. // comment
B. /* comment */
C. both // comment or /* comment */
D. // comment */
Explanation:
Both the ways are used for commenting in C++ programming. // is used for single line comments and /* … */ is used for multiple line comments.
8. Who created C++?
A. Bjarne Stroustrup
B. Dennis Ritchie
C. Ken Thompson
D. Brian Kernighan
Explanation:
Bjarne Stroustrup is the original creator of C++ during 1979 at AT&T Bell Labs.
9. 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
Explanation:
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.
10. 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
Explanation:
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.
11. 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
Explanation:
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.
12. 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)
Explanation:
C++ provides cin.get() function to read a single character from console whereas others are used to read either a single or multiple characters.