C++ Quizzes
Welcome to the world of C++ quizzes!
This platform is designed to help you test and improve your knowledge of the C++ programming language. With a variety of questions covering a range of topics, from basic to advanced, this quiz will challenge your understanding of C++ and help you stay ahead of the curve in the field. Whether you’re a beginner or an experienced programmer, you’re sure to find something that interests you. So, let’s get started and see how much you know about C++!
Quiz – C++ Basics Part 1
The quiz contains 16 questions and there is no time limit. You can get between 1 and 3 points for answering the questions correctly. At the end of the quiz, you'll receive a total score. You can compare yourself with other users via the leaderboard. If you achieve more than 70% you will be rewarded with a certificate. Good luck!
Test your understanding of the basics of C++ programming language: - Data types and variables - Arithmetic operators - Relational operators - Logical operators - Bitoperators - Functions
Quiz Summary
0 of 16 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 16 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 16
1. Question
2 point(s)What is the correct syntax to output
My first C++ program
?Correct 2 / 2 PointsIncorrect / 2 Points -
Question 2 of 16
2. Question
2 point(s)How do you create a variable with a decimal value of
4.6
in C++?(one or more answers)
CorrectIncorrect -
Question 3 of 16
3. Question
1 point(s)Select the appropriate data type for this value:
true
CorrectIncorrect -
Question 4 of 16
4. Question
1 point(s)What is the output for
a
?#include <iostream> using namespace std; int main() { int a = 10; double d = 2.5; a = d; cout << a; return 0; }
CorrectIncorrect -
Question 5 of 16
5. Question
1 point(s)What is the output for
a
?#include <iostream> using namespace std; int main() { short int a = 33000; cout << a; return 0; }
CorrectIncorrect -
Question 6 of 16
6. Question
1 point(s)Which operator can be used to increment a value?
CorrectIncorrect -
Question 7 of 16
7. Question
1 point(s)What is the output for
result
?#include <iostream> using namespace std; int main() { int a = 4; int b = 7; int c = 9; int result; result = ++a + --c * b; cout << result; return 0; }
CorrectIncorrect -
Question 8 of 16
8. Question
1 point(s)What is the output for
result
?#include <iostream> using namespace std; int main() { int a = 6; int b = 2; int result; result = --a * b++; cout << result; return 0; }
CorrectIncorrect -
Question 9 of 16
9. Question
1 point(s)Which operator can be used to check two values for inequality?
CorrectIncorrect -
Question 10 of 16
10. Question
1 point(s)What is the output for
result
?#include <iostream> using namespace std; int main() { int a = 100; int b = 40; int c = 7; int result; result = a % b % c; cout << result; return 0; }
CorrectIncorrect -
Question 11 of 16
11. Question
2 point(s)What is the output for
result
?#include <iostream> using namespace std; int main() { int a = 5; int b = 7; int c = 5; int result; a += c; b += c; result = (a + b) % 4; cout << result; return 0; }
CorrectIncorrect -
Question 12 of 16
12. Question
2 point(s)What is the output for
isSet
?#include <iostream> using namespace std; int main() { int x = 3; int y = 6; int z = 4; bool isSet = true; if (x < z && y >= z && x > z || isSet == true) { isSet = false; } cout << isSet; return 0; }
CorrectIncorrect -
Question 13 of 16
13. Question
2 point(s)What is the output for
isSet
?#include <iostream> using namespace std; int main() { int a = 50, b = 10, c = 20; if (c < b < a) { cout << "True"; } else { cout << "False"; } return 0; }
CorrectIncorrect -
Question 14 of 16
14. Question
3 point(s)What is the output for
x
?#include <iostream> using namespace std; int main() { int x, a = 11, b = 12; x = a | b; cout << x; return 0; }
CorrectIncorrect -
Question 15 of 16
15. Question
3 point(s)What is the output for
y
?#include <iostream> using namespace std; int main() { int x, y, a = 10, b = 14, c = 2; y = a ^ c; cout << y; return 0; }
CorrectIncorrect -
Question 16 of 16
16. Question
2 point(s)What is the output for
y
?#include <iostream> using namespace std; void fun(int val) { if (val > 16) { return; } cout << val; fun(val + 2); } int main() { fun(6); return 0; }
CorrectIncorrect
Quiz – C++ Basics Part 2
The quiz contains 17 questions and there is no time limit. You can get between 1 and 3 points for answering the questions correctly. At the end of the quiz, you'll receive a total score. You can compare yourself with other users via the leaderboard. If you achieve more than 70% you will be rewarded with a certificate. Good luck!
Test your understanding of the basics of C++ programming language: - Comments - Escape sequences - Data types - Operators - Control structures - Functions - Arrays
Quiz Summary
0 of 17 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 17 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 17
1. Question
2 point(s)Which is the correct way to write a comment in C++?
(one or more answers)
CorrectIncorrect -
Question 2 of 17
2. Question
1 point(s)Which is the correct way to write a multi line comment in C++?
CorrectIncorrect -
Question 3 of 17
3. Question
1 point(s)What is the output?
#include <iostream> using namespace std; int main() { int a = 5, b = 6; if (a >= b) { cout << a; } else { cout << b; } return 0; }
CorrectIncorrect -
Question 4 of 17
4. Question
1 point(s)What is the output for
c
?#include <iostream> using namespace std; int main() { int a = 2, b = 5, c = 0; while (c < 10) { if (a < b) { a++; c = c + 3; } else { c = c + 2; } } cout << c; return 0; }
CorrectIncorrect -
Question 5 of 17
5. Question
1 point(s)What is the output?
#include <iostream> using namespace std; int main() { int a = 0; double b = 0.0; bool output = a == b ? true : false; cout << output; return 0; }
CorrectIncorrect -
Question 6 of 17
6. Question
1 point(s)Which is the correct way to print a double quote (") in C++?
CorrectIncorrect -
Question 7 of 17
7. Question
1 point(s)Which is the correct way to print a vertical tab in C++?
CorrectIncorrect -
Question 8 of 17
8. Question
2 point(s)What is the output for
a
?#include <iostream> using namespace std; int main() { int a = 4, b = 12; while (b > a) { a++; if (a % 5 == 1) { break; } } cout << a; return 0; }
CorrectIncorrect -
Question 9 of 17
9. Question
1 point(s)What is the output?
#include <iostream> using namespace std; int main() { string s1 = "hello world"; string s2 = "hello World"; bool comp = !s1.compare(s2); cout << comp; return 0; }
CorrectIncorrect -
Question 10 of 17
10. Question
1 point(s)What is the output?
#include <iostream> using namespace std; int main() { int x = 6, y = 9, temp; temp = x; y++; temp--; x = y; y = temp; cout << x << ", " << y; return 0; }
CorrectIncorrect -
Question 11 of 17
11. Question
1 point(s)Multiple inheritance is not supported in C++?
CorrectIncorrect -
Question 12 of 17
12. Question
1 point(s)What is the output for
x
(how many loop passes)?#include <iostream> using namespace std; int main() { double a = 15, b = 6; int x = 0; while (a > b) { a--; b = b + 3; x++; } cout << x; return 0; }
CorrectIncorrect -
Question 13 of 17
13. Question
1 point(s)What is the output?
#include <iostream> using namespace std; int add(int a, int b) { int result; result = a + b; return result; } int main() { cout << add(5, 3); return 0; }
CorrectIncorrect -
Question 14 of 17
14. Question
2 point(s)What is the output?
#include <iostream> using namespace std; int add(int a, int b) { int result; result = a + b; return result; } int main() { cout << add(5.5, 3.3); return 0; }
CorrectIncorrect -
Question 15 of 17
15. Question
1 point(s)What is the output?
#include <iostream> using namespace std; int add(int x = 12) { return x + 1; } int main() { cout << add(5); return 0; }
CorrectIncorrect -
Question 16 of 17
16. Question
1 point(s)What is the output for
currentNumber
?#include <iostream> using namespace std; int main() { int numbers[] = {5, 6, 12, 9, 5, 18, 10, 5, 3, 19, 14}; int i = 0, currentNumber; currentNumber = numbers[0]; for (i = 1; i < 10; i++) { if (currentNumber < numbers[i]) { currentNumber = numbers[i]; } } cout << currentNumber; return 0; }
CorrectIncorrect -
Question 17 of 17
17. Question
2 point(s)What is the output?
#include <iostream> using namespace std; int main() { int myArray[3][2]; myArray[1][0] = 4; myArray[1][1] = 5; myArray[0][0] = 9; myArray[0][1] = 2; myArray[2][0] = 1; myArray[2][1] = 8; for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { cout << myArray[i][j]; } } return 0; }
CorrectIncorrect
Quiz – C++ Inheritance and Polymorphism
The quiz contains 13 questions and there is no time limit. You can get between 1 and 3 points for answering the questions correctly. At the end of the quiz, you'll receive a total score. You can compare yourself with other users via the leaderboard. If you achieve more than 70% you will be rewarded with a certificate. Good luck!
Test your understanding of inheritance and polymorphism: - Single inheritance - Multiple inheritance - Multilevel inheritance - Hierarchical inheritance - Compile-time polymorphism Function overloading Operator overloading - Runtime polymorphism Virtual function Function overriding
Quiz Summary
0 of 13 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 13 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 13
1. Question
1 point(s)What is the output?
#include <iostream> using namespace std; class Animal { public: Animal() { cout << "This is an Animal" << endl; } }; class Dog: public Animal { public: Dog() { cout << "This is a Dog" << endl; } }; int main() { Animal obj; return 0; }
CorrectIncorrect -
Question 2 of 13
2. Question
1 point(s)What is the output?
#include <iostream> using namespace std; class Animal { public: Animal() { cout << "This is an Animal" << endl; } }; class Dog: public Animal { public: Dog() { cout << "This is a Dog" << endl; } }; int main() { Dog obj; return 0; }
CorrectIncorrect -
Question 3 of 13
3. Question
1 point(s)What is the output?
#include <iostream> using namespace std; class Animal { public: Animal() { cout << "This is an Animal" << endl; } }; class Dog { public: Dog() { cout << "This is a Dog" << endl; } }; class Cat: public Animal, public Dog { public: Cat() { cout << "This is a Cat" << endl; } }; int main() { Dog obj; return 0; }
CorrectIncorrect -
Question 4 of 13
4. Question
2 point(s)What is the output?
#include <iostream> using namespace std; class Animal { public: Animal() { cout << "This is an Animal" << endl; } }; class Dog { public: Dog() { cout << "This is a Dog" << endl; } }; class Cat: public Animal, public Dog { public: Cat() { cout << "This is a Cat" << endl; } }; int main() { Cat obj; return 0; }
CorrectIncorrect -
Question 5 of 13
5. Question
1 point(s)What is the output?
#include <iostream> using namespace std; class Animal { public: Animal() { cout << "This is an Animal "; } }; class Dog: public Animal { public: Dog() { cout << "This is a Dog "; } }; class Cat: public Dog { public: Cat() { cout << "This is a Cat "; } }; int main() { Cat obj; return 0; }
CorrectIncorrect -
Question 6 of 13
6. Question
1 point(s)What is the output?
#include <iostream> using namespace std; class Animal { public: Animal() { cout << "This is an Animal "; } }; class Dog: public Animal { public: Dog() { cout << "This is a Dog "; } }; class Cat: public Dog { public: Cat() { cout << "This is a Cat "; } }; int main() { Dog obj; return 0; }
CorrectIncorrect -
Question 7 of 13
7. Question
1 point(s)What is the output?
#include <iostream> using namespace std; class Animal { public: Animal() { cout << "This is an Animal "; } }; class Dog: public Animal { public: Dog() { cout << "This is a Dog "; } }; class Cat: public Animal { public: Cat() { cout << "This is a Cat "; } }; int main() { Cat obj; return 0; }
CorrectIncorrect -
Question 8 of 13
8. Question
1 point(s)What is the output?
#include <iostream> using namespace std; void sum(int a, int b) { cout << a + b << " "; } void sum(int a, int b, int c) { cout << a + b + c << " "; } void sum(double a, double b) { cout << a + b << " "; } int main() { sum(6, 7); sum(5, 2, 32); sum(9.4, 4.6); return 0; }
CorrectIncorrect -
Question 9 of 13
9. Question
1 point(s)What is the output?
#include <iostream> using namespace std; void sum(int a, int b, int c) { cout << a + b + c << " "; } void sum(double a, double b) { cout << a + b << " "; } int main() { sum(6, 7); sum(9, 4, 3); return 0; }
CorrectIncorrect -
Question 10 of 13
10. Question
1 point(s)What is the output?
#include <iostream> using namespace std; void sum(int a, int b, int c) { cout << a + b + c << " "; } void sum(double a, double b) { cout << a + b << " "; } int main() { sum(6, 7); sum(6.2, 4.5, 2.3); return 0; }
CorrectIncorrect -
Question 11 of 13
11. Question
2 point(s)What is the output?
#include <iostream> using namespace std; class A { public: virtual void print() { cout << "class a output" << endl; } }; class B : public A { public: void print() { cout << "class b output" << endl; } }; class C : public A { public: void print() { cout << "class c output" << endl; } }; int main(void) { A *a; C c; a = &c; a->print(); return 0; }
CorrectIncorrect -
Question 12 of 13
12. Question
1 point(s)What is the output?
#include <iostream> using namespace std; class A { public: virtual void print() { cout << "class a output" << endl; } }; class B : public A { public: void print() { cout << "class b output" << endl; } }; class C : public A { public: void print() { cout << "class c output" << endl; } }; int main(void) { A *a; B *b; a = b; a->print(); return 0; }
CorrectIncorrect -
Question 13 of 13
13. Question
1 point(s)What is the output?
#include <iostream> using namespace std; class A { public: void print() { cout << "overridden method" << endl; } }; class B : public A { public: void print() { cout << "overriding method" << endl; } }; int main(void) { B b = B(); b.print(); return 0; }
CorrectIncorrect
Quiz – C++ Mathematical Rounding
The quiz contains 9 questions and there is no time limit. You can get between 1 and 3 points for answering the questions correctly. At the end of the quiz, you'll receive a total score. You can compare yourself with other users via the leaderboard. If you achieve more than 70% you will be rewarded with a certificate. Good luck!
Test your understanding of mathematical functions: - Basic mathematical functions - Mathematical rounding - Power math function - Square math function - Cubic math function
Quiz Summary
0 of 9 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 9 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 9
1. Question
1 point(s)What is the output?
#include <iostream> #include <cmath> using namespace std; int main() { double min, max; int a = 4, b = 6; min = fmin(a, b); max = fmax(a, b); cout << min << ", " << max << endl; return 0; }
CorrectIncorrect -
Question 2 of 9
2. Question
1 point(s)What is the output?
#include <iostream> #include <cmath> using namespace std; int main() { double ma, dim; int a = 4, b = 6, c = 3; // x*y+z without losing precision ma = fma(a, b, c); // positive difference of two floating point values dim = fdim(b, c); cout << ma << ", " << dim << endl; return 0; }
CorrectIncorrect -
Question 3 of 9
3. Question
1 point(s)What is the output for
rounding
?#include <iostream> #include <cmath> using namespace std; int main() { double value = 2.51245; // Round to nearest double rounding = round(value); cout << rounding << endl; return 0; }
CorrectIncorrect -
Question 4 of 9
4. Question
1 point(s)What is the output for
rounding
?#include <iostream> #include <cmath> using namespace std; int main() { double value = 2.41245; // Round to nearest double rounding = floor(value); cout << rounding << endl; return 0; }
CorrectIncorrect -
Question 5 of 9
5. Question
1 point(s)What is the output for
rounding
?#include <iostream> #include <cmath> using namespace std; int main() { double value = 2.41245; // Round to nearest double rounding = ceil(value); cout << rounding << endl; return 0; }
CorrectIncorrect -
Question 6 of 9
6. Question
1 point(s)What is the output for
rounding
?#include <iostream> #include <cmath> using namespace std; int main() { double value = 2.41245; // Round to nearest double rounding = trunc(value); cout << rounding << endl; return 0; }
CorrectIncorrect -
Question 7 of 9
7. Question
1 point(s)What is the output?
#include <iostream> #include <cmath> using namespace std; int main() { cout << pow(3, 3) << endl; return 0; }
CorrectIncorrect -
Question 8 of 9
8. Question
1 point(s)What is the output?
#include <iostream> #include <cmath> using namespace std; int main() { cout << sqrt(81) << endl; return 0; }
CorrectIncorrect -
Question 9 of 9
9. Question
1 point(s)What is the output?
#include <iostream> #include <cmath> using namespace std; int main() { cout << cbrt(216) << endl; return 0; }
CorrectIncorrect
Quiz – C++ Advanced
The quiz contains 9 questions and there is no time limit. You can get between 1 and 3 points for answering the questions correctly. At the end of the quiz, you'll receive a total score. You can compare yourself with other users via the leaderboard. If you achieve more than 70% you will be rewarded with a certificate. Good luck!
Test your advanced skills of the C++ programming language: - C++ Syntax - Advanced control structures - Classes and objects - Data abstraction - Functions
Quiz Summary
0 of 9 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 9 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 9
1. Question
1 point(s)C++ supports primarily static, but also dynamic type checking!
CorrectIncorrect -
Question 2 of 9
2. Question
1 point(s)C++ is a weakly-typed system!
CorrectIncorrect -
Question 3 of 9
3. Question
1 point(s)C++ is a type-safe language!
CorrectIncorrect -
Question 4 of 9
4. Question
1 point(s)C++ supports both manifest and inferred typing!
CorrectIncorrect -
Question 5 of 9
5. Question
2 point(s)What is the output for
sum
?#include <iostream> using namespace std; int main() { int sum = 0; for (int i = 0, j = 2; i < 6 & j < 10; i = j - i, j++) { sum += j; } cout << sum; return 0; }
CorrectIncorrect -
Question 6 of 9
6. Question
2 point(s)What is the output?
#include <iostream> using namespace std; int fun(int a, int b) { if (a == 0) { return b; } else { return a + fun(a - 1, b); } } int main() { cout << fun(1, 2); return 0; }
CorrectIncorrect -
Question 7 of 9
7. Question
1 point(s)What is the output?
#include <iostream> using namespace std; class Test { private: void privPrint() { cout << "A, "; } public: void pubPrint() { cout << "B, "; } protected: void protPrint() { cout << "C" << endl; } }; int main() { Test t1; t1.privPrint(); t1.pubPrint(); t1.protPrint(); return 0; }
CorrectIncorrect -
Question 8 of 9
8. Question
2 point(s)What is the output?
#include <iostream> using namespace std; class Test { private: void privPrint() { cout << "A, "; } public: void pubPrint() { cout << "B, "; } protected: void protPrint() { cout << "C" << endl; } }; int main() { Test t1; t1.pubPrint(); t1.protPrint(); return 0; }
CorrectIncorrectHint
No Access to protected methods
-
Question 9 of 9
9. Question
1 point(s)What is the output?
#include <iostream> using namespace std; class Test { private: void privPrint() { cout << "A"; } public: void pubPrint() { cout << "B"; } protected: void protPrint() { cout << "C" << endl; } }; int main() { Test t1; t1.pubPrint(); return 0; }
CorrectIncorrect