C++ Beginner Test

Time Elapsed: 0 seconds

1. What is the output of the following code?

    #include <iostream>
    using namespace std;
    int main() {
        cout << 5 + 3 * 2 << endl;
        return 0;
    }
    




2. Which keyword is used to define a constant in C++?





3. How do you declare a function in C++?





4. What is the output of the following code?

    #include <iostream>
    using namespace std;
    int main() {
        int x = 5;
        int y = 10;
        cout << (x == y) << endl;
        return 0;
    }
    




5. How do you create a vector in C++ with the elements 1, 2, and 3?

6. Explain the difference between std::vector and std::array in C++.

7. Write a C++ expression to check if the string "hello" contains the substring "ell".

8. What is the purpose of the auto keyword in C++?