In a hosted C++ program, which function does the operating system call to begin execution?
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.
Which name is a valid C++ identifier?
- A
2students - B
total-cost - C
student_name - D
return
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?
- A
A syntax error caused by a missing semicolon
- B
A run-time error caused by invalid input
- C
A preprocessing error caused by an include directive
- D
A linker error caused by a missing definition
Select all statements that correctly describe C++ comments.
- A
Comments are ignored when the program is translated.
- B
A
//comment continues through the entire source file. - C
A block comment can span multiple lines.
- D
Comments can document intent or assumptions.
Select all statements that correctly describe the basic C++ console stream objects and operators.
- A
std::coutnormally writes to standard output. - B
std::cinnormally reads formatted input from standard input. - C
std::cin << valueis the usual way to read a value. - D
The
std::prefix identifies a name from the standard library namespace.
True or false: A C++ comment is compiled into an instruction that the processor executes.
- A
True
- B
False
True or false: A function definition normally requires a semicolon immediately after its closing brace.
- A
True
- B
False
What is the name of the standard output stream object normally used to write to the console?
What integer value does the C++ expression 2 + 3 * 4 produce?
In C++, the operator sends values to an output stream, while the operator reads formatted values from an input stream.
After source files have been compiled into object files, combines those files and resolves references. The operating system then loads the executable during .
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.
Which declaration follows the material's recommended modern convention of initializing an object with braces when it is created?
- A
double temperature = 21.5; - B
double temperature{21.5}; - C
temperature double{21.5}; - D
double{temperature} = 21.5;
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?
- A
The first function defined in the source file
- B
The global
mainfunction - C
The first statement after
#include - D
The function with the most parameters
In C++, comments are ignored during translation and do not produce executable behavior.
- A
True
- B
False
Which proposed variable name is invalid in C++ under the identifier rules described in the material?
- A
student_name - B
item2 - C
total-cost - D
numberOfStudents
Which C++ operator sends a value to an output stream such as std::cout?
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?
- A
Compilation translates a source file into an object file; linking combines object files and libraries.
- B
Compilation runs the executable; linking formats the source code.
- C
Compilation resolves all library references; linking checks only indentation.
- D
Compilation and linking are two names for preprocessing.
What namespace prefix appears before standard-library objects such as cout and cin?
What value is assigned to result by this statement?
int result = 2 + 3 * 4;
- A
20
- B
24
- C
14
- D
10