Free Practice Quiz Question List

1 C++ Foundations and Syntax Online Quiz Questions

Use this free practice quiz with 20 questions to review 1 C++ Foundations and Syntax, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

In a hosted C++ program, which function does the operating system call to begin execution?

  1. A

    The global function named start

  2. B

    The global function named main

  3. C

    The first function listed in the source file

  4. D

    The first statement after #include

02
Choose one
1 point

Which name is a valid C++ identifier?

  1. A

    2students

  2. B

    total-cost

  3. C

    student_name

  4. D

    return

03
Choose one
1 point

A C++ source file passes compilation, but the build cannot construct the final executable because a required function definition is missing. What kind of error is this?

  1. A

    A syntax error caused by a missing semicolon

  2. B

    A run-time error caused by invalid input

  3. C

    A preprocessing error caused by an include directive

  4. D

    A linker error caused by a missing definition

04
Choose all
1 point

Select all statements that correctly describe C++ comments.

  1. A

    Comments are ignored when the program is translated.

  2. B

    A // comment continues through the entire source file.

  3. C

    A block comment can span multiple lines.

  4. D

    Comments can document intent or assumptions.

05
Choose all
1 point

Select all statements that correctly describe the basic C++ console stream objects and operators.

  1. A

    std::cout normally writes to standard output.

  2. B

    std::cin normally reads formatted input from standard input.

  3. C

    std::cin << value is the usual way to read a value.

  4. D

    The std:: prefix identifies a name from the standard library namespace.

06
True or false
1 point

True or false: A C++ comment is compiled into an instruction that the processor executes.

  1. A

    True

  2. B

    False

07
True or false
1 point

True or false: A function definition normally requires a semicolon immediately after its closing brace.

  1. A

    True

  2. B

    False

08
Written response
1 point

What is the name of the standard output stream object normally used to write to the console?

09
Written response
1 point

What integer value does the C++ expression 2 + 3 * 4 produce?

10
Fill in the blank
1 point

In C++, the operator sends values to an output stream, while the operator reads formatted values from an input stream.

11
Fill in the blank
1 point

After source files have been compiled into object files, combines those files and resolves references. The operating system then loads the executable during .

12
Open ended
1 point

Explain the difference between compilation, linking, and run time in the C++ translation process. Include what happens at each stage and when a missing function definition would typically be detected.

13
Choose one
1 point

Which declaration follows the material's recommended modern convention of initializing an object with braces when it is created?

  1. A

    double temperature = 21.5;

  2. B

    double temperature{21.5};

  3. C

    temperature double{21.5};

  4. D

    double{temperature} = 21.5;

14
Choose one
1 point

A hosted C++ program contains several functions, but none of them is necessarily written first in the source file. Which function does the operating system use as the program's starting point?

  1. A

    The first function defined in the source file

  2. B

    The global main function

  3. C

    The first statement after #include

  4. D

    The function with the most parameters

15
True or false
1 point

In C++, comments are ignored during translation and do not produce executable behavior.

  1. A

    True

  2. B

    False

16
Choose one
1 point

Which proposed variable name is invalid in C++ under the identifier rules described in the material?

  1. A

    student_name

  2. B

    item2

  3. C

    total-cost

  4. D

    numberOfStudents

17
Written response
1 point

Which C++ operator sends a value to an output stream such as std::cout?

18
Choose one
1 point

A project has two source files, and each source file compiles successfully, but the final executable cannot be constructed because a required function definition is missing. Which statement best distinguishes the relevant stages?

  1. A

    Compilation translates a source file into an object file; linking combines object files and libraries.

  2. B

    Compilation runs the executable; linking formats the source code.

  3. C

    Compilation resolves all library references; linking checks only indentation.

  4. D

    Compilation and linking are two names for preprocessing.

19
Written response
1 point

What namespace prefix appears before standard-library objects such as cout and cin?

20
Choose one
1 point

What value is assigned to result by this statement?

int result = 2 + 3 * 4;

  1. A

    20

  2. B

    24

  3. C

    14

  4. D

    10