Free Practice Quiz Question List

01 C++ Fundamentals and Program Structure Online Quiz Questions

Use this free practice quiz with 20 questions to review 01 C++ Fundamentals and Program Structure, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

Which part of a C++ program defines its entry-point function?

  1. A

    std::cout

  2. B

    main

  3. C

    #include <iostream>

  4. D

    return 0;

02
True or false
1 point

True or false: C++ comments are ignored during translation.

  1. A

    True

  2. B

    False

03
Written response
1 point

What is the technical term for the source produced after an included file's contents are conceptually incorporated and prepared for compilation?

04
Fill in the blank
1 point

The build stage that handles directives such as #include before ordinary compilation is called .

05
Choose one
1 point

Which operator is used in std::cin >> age; to read formatted input into age?

  1. A

    <<

  2. B

    =

  3. C

    >>

  4. D

    >

06
True or false
1 point

True or false: When placed between valid tokens, spaces, tabs, and line breaks generally do not change a C++ program's meaning.

  1. A

    True

  2. B

    False

07
Choose all
1 point

Which of the following are standard streams provided by the <iostream> header? Select all correct choices.

  1. A

    std::cout

  2. B

    std::cin

  3. C

    std::cerr

  4. D

    std::clog

  5. E

    std::fstream

08
Written response
1 point

In the example program, if year is entered as 2000 and current_year is 2026, what integer value is stored in approximate_age?

09
Fill in the blank
1 point

A typical build proceeds from preprocessing to , which generates lower-level code, and then to , which combines object files and libraries into an executable.

10
Choose one
1 point

What happens when the command g++ -c greeting.cpp -o greeting.o is used?

  1. A

    It runs the executable after building it.

  2. B

    It stops after compilation and does not link.

  3. C

    It preprocesses only and produces no object file.

  4. D

    It enables line-by-line debugging.

11
Choose all
1 point

Which choices are lexically valid programmer-defined identifiers in C++? Select all correct choices.

  1. A

    item_count

  2. B

    2value

  3. C

    Value2

  4. D

    class

  5. E

    _temporary

12
Open ended
1 point

Why can std::getline(std::cin, line) appear to read an empty line immediately after std::cin >> number, and how does std::getline(std::cin >> std::ws, line) address the problem?

13
Choose one
1 point

Which statement correctly distinguishes the literals "C++" and 'A'?

  1. A

    'C++' is a character literal containing several characters.

  2. B

    "C++" is a character literal and 'A' is a string literal.

  3. C

    "C++" is a string literal and 'A' is a character literal.

  4. D

    Both forms are interchangeable representations of the same literal type.

14
Choose one
1 point

A build command processes #include <iostream> before the compiler generates object code. Which build stage handles this directive?

  1. A

    Compilation

  2. B

    Preprocessing

  3. C

    Linking

  4. D

    Execution

15
Choose one
1 point

A program reads an integer with std::cin >> number and then must read a complete line into line, including spaces. Which approach correctly avoids having std::getline consume the leftover newline?

  1. A

    Call std::getline twice

  2. B

    Replace std::getline with std::cin >> line

  3. C

    Use std::getline(std::cin >> std::ws, line)

  4. D

    Add a second integer variable before reading the line

16
Choose one
1 point

A source file includes a header, and the included contents are incorporated before ordinary compilation. What is the resulting source being processed conceptually called?

  1. A

    translation unit

  2. B

    Only the original .cpp file before preprocessing

  3. C

    The final executable after linking

  4. D

    Only the header file by itself

17
Choose one
1 point

Which combination correctly sends the text Ready and the value of count to standard output in one statement?

  1. A

    std::cin with >>

  2. B

    std::cerr with <<

  3. C

    std::cout with >>

  4. D

    std::cout with <<

18
True or false
1 point

True or false: A C++ block comment can span several lines, and the comment itself is ignored during translation.

  1. A

    True

  2. B

    False

19
Written response
1 point

In C++, what operator inserts a value into an output stream such as std::cout?

20
Written response
1 point

A program uses the formula approximate_age = current_year - year with current_year = 2026. If approximate_age is 17, what birth year does the program infer?