Question: 1. Passing by reference is always safer than passing by value. Is this statement true or false? a)True b)False 2. Every if statement must have

1. Passing by reference is always safer than passing by value. Is this statement true or false?

a)True

b)False

2. Every if statement must have a condition. This statement is

a) true

b) false

Every else statement must have a condition. This statement in...a) true b)false

3.

Consider this block of code:

int foo(int a){ return a; }

int main(int argc, char** argv){ int b; cout << foo(b); return 0; }

I)The integer a being used is a/an....a)condintion b)reference c)parameter d)argument

II) The integer b is being used as a/an...a)parameter. b)condition c)argument. d) reference

4.

Select the best option below that identifies a problem with this struct definition.

struct Car{ string license_plate; float miles_per_gallon; string color; }

a)The name "Car" is too short.

b)The struct members must be named in camelCase, not snake_case.

c)Three is not enough members to make a struct.

d)The struct definition must ber terminated with a semicolon;

5.

Select every option below that is a valid return type for a function in C++.

a)bool

b)struct

c)void

d)const

6.

Identify one issue in the code below:

int main(int argc, char** argv){ int a = 2; while(a > 0){ a *= 2; } cout << "Loop complete." << endl; return 0; }

a)There is an infinite loop in this code.

b)0 is not a valid return for the main function.

c)The while loop would be more efficient as a for loop.

d)The integer a is out of bounds.

7.

Referencing an array out of bounds will always cause a program written in C++ to crash. Is this statement true or false?

a)True

b)False

8.

Which C++ keyword can be used to prevent a function with a reference parameter from altering the value of variables passed to it as arguments? Select the best answer from below.

Group of answer choices

a)static

b)for

c)const

d)&

9.

Select the best option below that identifies a problem with this function definition.

bool foo(struct a){ if (a.x > 5) return true; else return false; }

a)The body of an if statement must be enclosed in {curly brackets}.

b)struct is not a valid datatype.

c)There is no default return statement.

d)The if should be implemented as a switch.

10.

How many return statements can be included in a function? Select the best answer from the choices below.

a)Zero or one.

b)More than zero and less than five.

c)Only one.

d)Any number.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!