Can You Pass This C++ Programming Test? Quiz

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Rmyers
R
Rmyers
Community Contributor
Quizzes Created: 2 | Total Attempts: 1,450
Questions: 10 | Attempts: 1,211

SettingsSettingsSettings
Can You Pass This C++ Programming Test? Quiz - Quiz

C++ is a high-level language that programmers need to have some necessary information on. We got to discuss how to use it to achieve the right functions of the central processing unit. This quiz contains 10 questions that pertain to the material you learned in Chapter 1. Give it a try and get to see how much you recall. All the best!


Questions and Answers
  • 1. 

    Given the enumeration defined by the following line, what is the value of UNBEATABLE ? enum difficulty {NOVICE=1, EASY, NORMAL, HARD, UNBEATABLE};

    • A.

      1

    • B.

      2

    • C.

      3

    • D.

      4

    • E.

      5

    Correct Answer
    E. 5
    Explanation
    The value of UNBEATABLE is 5 because in the enumeration, the values are assigned starting from 1, and each subsequent value is incremented by 1. Therefore, UNBEATABLE is assigned the value of 5.

    Rate this question:

  • 2. 

    What is the value of lives and bonus after the following code is run... int lives = 3; int bonus = 0; bonus = lives++ * 10;

    • A.

      Lives = 4 and bonus = 30

    • B.

      Lives = 3 and bonus = 30

    • C.

      Lives = 3 and bonus = 40

    • D.

      Lives = 4 and bonus = 40

    Correct Answer
    A. Lives = 4 and bonus = 30
    Explanation
    The code first assigns the value of lives (which is 3) to bonus. Then, the value of lives is incremented by 1 using the postfix increment operator. Therefore, lives becomes 4. However, the value of bonus remains 30 because it was assigned the original value of lives before the increment.

    Rate this question:

  • 3. 

    Name one reason that game programmers choose C++. Use a one word answer.

    Correct Answer
    flexible
    fast
    well-supported
    Explanation
    C++ is a popular choice for game programmers because it offers flexibility, allowing them to write code that can be easily adapted and modified. Additionally, C++ is known for its speed and efficiency, making it ideal for creating high-performance games. Lastly, C++ has a strong and extensive support system, with a large community of developers and resources available, making it easier for programmers to find help and solutions to any issues they may encounter.

    Rate this question:

  • 4. 

    What must statements in C++ end with?

    Correct Answer
    semicolon
    ;
    semi-colon
    semi colon
    Explanation
    In C++, statements must end with a semicolon (;). This is a fundamental rule in the syntax of the language. The semicolon acts as a delimiter, indicating the end of a statement and allowing the compiler to properly interpret the code. Forgetting to include a semicolon at the end of a statement can result in a compilation error. Therefore, it is important to remember to always end statements in C++ with a semicolon.

    Rate this question:

  • 5. 

    All C++ programs must have at least one function called main()?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    All C++ programs must have at least one function called main(). This is because the main() function is the entry point of the program, where the execution starts. Without a main() function, the program would not have any instructions to execute and would not be able to run. Therefore, it is a requirement for all C++ programs to have a main() function.

    Rate this question:

  • 6. 

    C++ is the most prevalent language in the computer game industry.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    C++ is the most prevalent language in the computer game industry because it offers high performance and low-level control over hardware, making it suitable for developing complex and resource-intensive games. Additionally, C++ has a large number of libraries and frameworks specifically designed for game development, making it easier and more efficient for developers to create games. Its widespread use in the industry also means that there is a wealth of resources and support available for C++ game development.

    Rate this question:

  • 7. 

    Dividing two integers (7/3) can sometimes yield a decimal point number.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    When dividing two integers, the result can either be a whole number or a fraction. In this case, dividing 7 by 3 gives a quotient of 2 with a remainder of 1. Therefore, the result is not a decimal point number, making the statement false.

    Rate this question:

  • 8. 

    Variable names of constants must be in uppercase letters according to C++ rules?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    In C++, variable names of constants do not necessarily have to be in uppercase letters. While it is a common convention to use uppercase letters for constant names to make them more distinguishable from regular variables, it is not a strict rule enforced by the language. The choice of naming conventions for constants is ultimately up to the programmer's preference and the coding style guidelines followed by the project. Therefore, the statement that variable names of constants must be in uppercase letters is false.

    Rate this question:

  • 9. 

    When you declare a variable, you must give it a type.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    When declaring a variable, it is necessary to specify its type. This is because the type determines the kind of data that can be stored in the variable and the operations that can be performed on it. Without specifying a type, the programming language would not know how to allocate memory for the variable or how to interpret the data stored in it. Therefore, it is essential to provide a type when declaring a variable.

    Rate this question:

  • 10. 

    You must always assign a value to a variable when you first declare it.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    When declaring a variable, it is not always necessary to assign a value to it. Variables can be declared without an initial value, and their value can be assigned later in the program. This allows for flexibility in programming, as variables can be declared first and assigned a value when needed. Therefore, the statement "You must always assign a value to a variable when you first declare it" is false.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 24, 2010
    Quiz Created by
    Rmyers
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.