Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

14. The ___________ statement is used to repeat one or more actions when a condition is true or skip the action(s) when the condition is

14.

The ___________ statement is used to repeat one or more actions when a condition is true or skip the action(s) when the condition is false.

a. case
b. while
c. if
d.

const

17.

Consider the following function prototype: void helloworld(std::vector& myvector)

Assuming the main function creates a vector named myvector and fills it with data, write a statement that will properly call this function. Do not put any spaces in your answer.

20.Assume the following is found in a class member function. The variable x is not a class member variable. There is a #include in the client file, but not in the header file. Which of the following statements will correct the first line of this code?

For ( x = 0, x >= 100, x++ ) std::cout << x << std::endl;

a.No change is needed
b. for(x == 0: x > 100: x++)
c. for(int x = 0, x => 100, x++)

d. for(int x = 0; x <= 100; x++)

21.

Consider the following function implementation. #include void print_me( ) { std::cout << "Hello World "; }

Write a statement to properly call this function. Do not put spaces in your answer.

24.

Which of the following lines of code will display the contents of the variable called first? Assume no errors.

a. std::cout >> first;
b. std::cin >> first;
c. std::cout << first;
d.

std::cin << first;

25.

Consider the following function implementation: void myvariables::getvalues() { //local variables int count; std::string first, last; }

The myvariables class contains a private data member called count that is set to the value 100 before this function is called. If this function included the following line as the last line of this function, what would the result be? std::cout << count;

a. A syntax error
b. Unpredictable or 0
c.

100

26.

Which would you use to add together all of the elements in a vector of integers?

a.case statement
b. if statement
c.

for loop

27. Which would you use to determine whether the contents of var1 and var2 are not equal? Type what is missing from this if statement:

if(var1 ____ var2)

28.

Consider the following function implementation: void scores::displayScores() { for (int i = 0; i < stats.size(); i++) { std::cout << stats[i] << std::endl; total = total + stats[i]; }

Which type of variable is total?

a. nonmember variable
b. local variable
c. class member variable
d.

total is not a variable, it is a function

30.

Consider the following function prototypes. Assume that both of these functions will add 100 to the existing value stored in the variable called num when the function is called. void passbyValue(int num); void passbyRef(int &num); The following function calls are made from the main function: int original_num = 1; passbyValue(original_num); passbyRef(original_num);

What is the value in original_num after these calls are completed? Provide the integer value in the box below.

31.

Consider the following member function: int myclass::addition (int a, int b) { int r; r=a+b; }

What is wrong with this function?

a. The variable definition is wrong.
b. The calculation is wrong.
c. The parameter list is wrong.
d.

Something is missing.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions