0
0
C++programming~10 mins

Why C++ is widely used - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print a message about C++ usage.

C++
#include <iostream>

int main() {
    std::cout << "C++ is widely used because it is [1]." << std::endl;
    return 0;
}
Drag options to blanks, or click blank then click option'
Aobsolete
Bslow
Cfast
Dcomplicated
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'slow' or 'obsolete' which are incorrect descriptions.
2fill in blank
medium

Complete the code to declare a variable showing C++'s feature.

C++
#include <iostream>

int main() {
    bool isObjectOriented = [1];
    std::cout << "C++ supports object-oriented programming: " << isObjectOriented << std::endl;
    return 0;
}
Drag options to blanks, or click blank then click option'
Atrue
B0
C"yes"
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using string "yes" instead of boolean true.
3fill in blank
hard

Fix the error in the code to correctly define a function that returns C++'s main advantage.

C++
#include <string>

std::string mainAdvantage() {
    return [1];
}
Drag options to blanks, or click blank then click option'
A42
B"performance"
Cperformance
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Returning an unquoted word causing a compile error.
4fill in blank
hard

Fill both blanks to create a map of C++ features and their descriptions.

C++
#include <iostream>
#include <map>
#include <string>

int main() {
    std::map<std::string, std::string> features = {
        {"[1]", "Supports low-level memory manipulation"},
        {"[2]", "Supports object-oriented programming"}
    };
    for (const auto& [key, value] : features) {
        std::cout << key << ": " << value << std::endl;
    }
    return 0;
}
Drag options to blanks, or click blank then click option'
APointers
BInheritance
CTemplates
DGarbage Collection
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'Garbage Collection' which C++ does not have by default.
5fill in blank
hard

Fill all three blanks to create a function that returns a feature description based on input.

C++
#include <string>

std::string featureDescription(const std::string& feature) {
    if (feature == "[1]") {
        return "Allows code reuse and polymorphism.";
    } else if (feature == "[2]") {
        return "Enables generic programming.";
    } else if (feature == "[3]") {
        return "Provides control over system resources.";
    } else {
        return "Unknown feature.";
    }
}
Drag options to blanks, or click blank then click option'
AInheritance
BTemplates
CPointers
DGarbage Collection
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing garbage collection with pointers or templates.