C++ Fundamentals | Set 2
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
Answer: B
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)
Answer: A
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.
13. 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
Explanation: C++ provides cout.put() function to write a single character to console whereas others are used to write either a single or multiple characters.
14. What is a constant that contains a single character enclosed within single quotes?
a) Numeric
b) Fixed
c) Character
d) Floating Point
Answer: C
Explanation: No explanation is given for this question.
15. A C++ code line ends with ___
a) A Semicolon (;)
b) A Fullstop(.)
c) A Comma (,)
d) A Slash (/)
Answer: A
Explanation: No explanation is given for this question.
16. 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
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.
17. Which of the following escape sequence represents carriage return?
a) \r
b) \n
c) \n\r
d) \c
Answer: A
Explanation: \r is used to represent carriage return which means move the cursor to the beginning of the next line.
18. Which of the following escape sequence represents tab?
a) \t
b) \t\r
c) \b
d) \a
Answer: A
Explanation: \t is used to represent tab which means a set of blank spaces in a line.
19. Which of the following is called insertion/put to operator?
a) >>
b) <<
c) >
d) <
Answer: B
Explanation: << operator is called insertion or put to operator i.e. insert/put things to console/files.
20. Which of the following is called extraction/get from operator?
a) <<
b) >>
c) >
d) <
Answer: B
Explanation: >> operator is called extraction or get from operator i.e. extract/get things from console/files.