Challenge - 5 Problems
C++ Mastery: Why C++ is widely used
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Why is C++ preferred for system-level programming?
Which of the following reasons best explains why C++ is widely used for system-level programming?
Attempts:
2 left
💡 Hint
Think about what system-level programming needs in terms of speed and control.
✗ Incorrect
C++ is widely used for system-level programming because it allows direct memory manipulation and produces fast, efficient code.
❓ Predict Output
intermediate2:00remaining
Output of C++ code using classes and pointers
What is the output of the following C++ code?
C++
#include <iostream> using namespace std; class Box { public: int length; Box(int l) : length(l) {} int getLength() { return length; } }; int main() { Box* b = new Box(10); cout << b->getLength() << endl; delete b; return 0; }
Attempts:
2 left
💡 Hint
Look at how the object is created and accessed through a pointer.
✗ Incorrect
The code creates a Box object with length 10 and prints it using pointer syntax, so output is 10.
❓ Predict Output
advanced2:00remaining
Output of C++ code with virtual functions and inheritance
What is the output of this C++ program?
C++
#include <iostream> using namespace std; class Base { public: virtual void show() { cout << "Base" << endl; } }; class Derived : public Base { public: void show() override { cout << "Derived" << endl; } }; int main() { Base* b = new Derived(); b->show(); delete b; return 0; }
Attempts:
2 left
💡 Hint
Think about how virtual functions work with pointers to base class.
✗ Incorrect
Because show() is virtual, the Derived class version is called even when accessed via Base pointer.
🧠 Conceptual
advanced2:00remaining
Why does C++ support both procedural and object-oriented programming?
Why is C++ designed to support both procedural and object-oriented programming styles?
Attempts:
2 left
💡 Hint
Think about flexibility and programmer choice.
✗ Incorrect
C++ supports multiple programming styles so developers can pick what fits their needs best.
🧠 Conceptual
expert3:00remaining
Why is C++ still widely used despite newer languages?
Which reason best explains why C++ remains widely used even though many newer programming languages exist?
Attempts:
2 left
💡 Hint
Consider what makes C++ unique compared to newer languages.
✗ Incorrect
C++ gives programmers fine control over system resources and performance, which newer languages often abstract away.