Ch. 8 - C++ introduction
A C++ function must return a value (T/F)
False
A C++ program that compiles will output the results you intend it to (T/F)
False
A C++ program that solves a specific problem such as sorting numbers will always execute faster on the same computer than a Python program that solves the same problem. (T/F)
False
C++ compiler warnings should be ignored.(T/F)
False
If you compile a C++ program using the Linux operating system on an Intel chip, you can execute the generated program on a computer running the Windows operating system on the same Intel chip. (T/F)
False
For simple text-based programs you can usually recompile a C++ program on different architectures and operating systems without changing your code (T/F)
True
In general, a compiled C++ will execute faster than a similar Python program on the same computer (T/F)
True
If a C++ function uses a variable that has not been declared, what happens? a- The code will not compile. b- When executing that function, an error message will be generated similar to Python's NameError message c- The program crashes d- None of the above
a
The linker a- combines machine code from multiple files to produce an executable program b- compiles a C++ file into machine code c- copies header files into a C++ file d- loads a program into memory and executes it
a
Which of the following is not true about the C++ pass by reference mechanism? a- A copy of the actual parameter is made b- All changes to the formal parameter that are made in the function affect the actual parameter c- It allows you to effectively return multiple values calculated by the function d- It is slower than pass by value
a
Compiling a C++ file that does not contain a main function produces a- an executable program b- an object file containing the machine code for that C++ file c- another C++ file d- None of the above
b
What is the main purpose of a header file? a- to comment the code in a source file b- to declare items so they can be used in C++ source files c- to define items so they can be used in C++ source files d- None of the above
b
Which of the following programs would you expect to be significantly faster when written in C++ than when written in Python? a- a program to convert miles to kilometers b- a program with a loop that runs a million times c- a program with a loop that runs 10 times d- All of the above
b
C++ functions can return a- C++ functions do not return a value b- arrays c- at most one variable or expression d- multiple variables or expressions
c
The scope of a variable refers to a- the name of the variable b- the different values it can hold c- where the variable can accessed d- the time during which memory is allocated for the variable
c
Which of the following is true about C++ arrays? a- Arrays can be returned by a function b- Arrays include a method to sort the values in the array c- Arrays can be passed by value d- The values in the array must be the same type
d
Which of the following statements is most similar in Python and C++? a- the for statement b- a function definition c- the if/else statement d- the while statement
d
A C++ program that does not compile can be executed. (T/F)
false
If the C++ compiler outputs a warning, it will never compile the program. (T/F)
false
Passing an int type by reference is faster and more efficient than passing an int type by value. (T/F)
false
All C++ programs must have a function named main. (T/F)
true
Any variable used in a C++ program must be declared with a type before it can be used. (T/F)
true