C++ Fundamentals | Set 3
21. A language which has the capability to generate new data types are called ________________
a) Extensible
b) Overloaded
c) Encapsulated
d) Reprehensible
Answer: A
Explanation: Languages that can produce/generate new data types are called extensible languages as they have the ability to handle new data types.
22. Which of the following is not a fundamental type is not present in C but present in C++?
a) int
b) float
c) bool
d) void
Answer: C
Explanation: Boolean type is not present as a fundamental type in C. int type is used as boolean in C whereas in C++ bool is defined as a fundamental type for handling boolean outputs.
23. What is the size of a boolean variable in C++?
a) 1 bit
b) 1 byte
c) 4 bytes
d) 2 bytes
Answer: A
Explanation: Boolean uses only 1 bit as it stores only truth values which can be true(1) or false(0).
24. Which of the following is C++ equivalent for scanf()?
a) cin
b) cout
c) print
d) input
Answer: A
Explanation: C++ uses cin to read input form uses. However C++ also uses scanf().
25. Which of the following is C++ equivalent for printf()?
a) cin
b) cout
c) print
d) input
Answer: B
Explanation: C++ uses cout to print output to console. However C++ also uses printf().
26. Which of the following is the correct difference between cin and scanf()?
a) both are the same
b) cin is a stream object whereas scanf() is a function
c) scanf() is a stream object whereas cin is a function
d) cin is used for printing whereas scanf() is used for reading input
Answer: B
Explanation: cin is a stream object available in C++ whereas scanf() is a function available in both C and C++. both are used for reading input from users.
27. Which of the following is an exit-controlled loop?
a) for
b) while
c) do-while
d) all of the mentioned
Answer: C
Explanation: do-while is called exit controlled loop because in do-while termination condition is checked when we have executed the body of the loop i.e. we are exiting the body and then checking the condition, therefore, it is called exit controlled loop.
28. Which of the following is an entry-controlled loop?
a) for
b) while
c) do-while
d) both while and for
Answer: D
Explanation: Both while and for loops are called entry controlled loop because in both of them the termination condition is checked before we enter the body of the loop hence they are called entry controlled loop.
29.In which part of the for loop termination condition is checked?
for(I;II;III)
a) I
b) II
c) III
d) IV
Answer: B
Explanation: In II part the termination condition of the for loop is checked.
30. Which of the following is the scope resolution operator?
a) .
b) *
c) ::
d) ~
Answer: C
Explanation: :: operator is called scope resolution operator used for accessing a global variable from a function which is having the same name as the variable declared in the function.