C++ MCQ Questions and Answers – Part 2
Multiple choice questions and answers (MCQs) on C++ to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are taken from an interview. So you will find questions on basic techniques such as Variables, Operators, Conditional Statement, Functions, and more. This quiz will easily prepare anyone to pass their online test.
1. What is the output of the following C++ program?
#include <iostream> using namespace std; int main() { cout << sizeof(char); cout << sizeof(int); cout << sizeof(float); return 0; }
A 1 8 8
B 1 4 8
C 1 4 4
D Aucune de ces rĂ©ponses n’est vraie.
2. Which function is used to read a single character in the console in C++?
A scanf(c)
B read(c)
C getline(c)
D cin.get(c)
[st_adsense]
3. Which function is used to write a single character to the console in C++?
A printf(c)
B write(c)
C cout.put(c)
D cout.putline(c)
4. The size of an object or type can be determined with which operator?
A malloc
B sizeof
C malloc
D calloc
5. How many times does the “cout” in line 12 run?
#include <iostream> using namespace std; int main() { int n = 10; for (int i = 0; i < n; i++ ) { n++; continue; cout << n; } return 1; }
A 10
B 11
C 1
D The “cout” never runs.
[st_adsense]
6. Which of the following operators is called “Input Flow Operator”?
A <<
B >>
C >
D <
7. Which of the following operators is called “Output Flow Operator”?
A <<
B >>
C >
D <
8. A language able to generate new data types is called _________
A overloaded
B extensible
C encapsulated
D scalable
9. What is the output of the following C++ code?
#include <iostream> using namespace std; int main() { int n = 5, i; for (i = 0; i < n; i++) { n++; cout << n << endl; goto a; } a: do { cout << "label a" << endl; break; } while( 0 ); return 1; }
A 5 label a
B 5
C label a
D 6
label a
10. The size of objects in C++ is expressed in terms of multiples of ____ size and the size of a “char” is _______
A char, 4
B int, 1
C char, 1
D float, 8
[st_adsense]