Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 1 Passing a structure as a constant reference parameter to a function:

ID: 2246362 • Letter: Q

Question

QUESTION 1

Passing a structure as a constant reference parameter to a function:           

can potentially result in changes to the structure's members.

guarantees not to result in changes to the structure's members.

will always change the structure's members.

All of the above

QUESTION 2

Before a structure can be used, it must be

declared

deallocated

initialized

All of the above

QUESTION 3

This allows you to access structure members.

structure access operator

dot operator

#include <structaccess> directive

getmember function

QUESTION 4

Which of the following statements outputs the value of the gpa member of element 1 of the student array?

cout << student1.gpa;

cout << firstStudent.gpa;

cout << student[1].gpa;

cout << student1->gpa;

QUESTION 5

Look at the following structure declaration.

struct Employee

{

string name;

int idNum;

};

In this declaration, Employee is

a member

a tag

an array

None of the above

QUESTION 6

        A struct can contain members with varying data types.

True

False

QUESTION 7

Which of the following headers must be included for class string?

<iostream>

std

<string>

None of the above

QUESTION 8

Class string belongs to which namespace?

std

<string>

<iostream>

All of the above

QUESTION 9

Class string provides overaloaded ==, !=, <, >, <=, and >= operators for string comparisons

True

False

QUESTION 10

String member function compare compares two strings (or substrings) and returns 0 if:

The strings are not equal

the strings are equal

if the first string is greater than the second

All of the above.

QUESTION 11

When a derived class has two or more base classes, the situation is knows as :

multiple inheritance

polymorphism

encapsulation

access specification

QUESTION 12

In the following statement:

class Car : protected Vehicle

Which is the derived class?
    

Car

Vehicle

protected

cannot be determined

QUESTION 13

When member functions behave differently, depending upon which object performed the call, this is an example of:

inheritance

polymorphism

encapsulation

None of the above

QUESTION 14

In an inheritance situation, you may not pass arguments to a base class constructor.

True

False

QUESTION 15

A member function of a derived class may not have the same name as a member function of a base class

True

False   

QUESTION 16

Pointers to a base class may be assigned the address of a derived class object.

True

False

QUESTION 17

In an inheritance situation, the new class that you create from an existing class is known as the:

derived class

inheritee

child class

A and C

QUESTION 18

Which term allows us to create new classes based on existing classes.

Polymorphism

Inheritance

Function Overloading

The copy constructor

QUESTION 19

Every preprocessing directive must begin with:

#undef

#

#define

whitespace

QUESTION 20

The #elif and #else directives are provided as shorthand notation for the #if defined(name) and #if !defined(name).

True

False

QUESTION 21

Which term enables you to control the execution of preprocessing directives and the compilation of program code?

Conditional Compilation

Macro

#define directive

preprocessor

QUESTION 22

The #undef directive discards symbolic constant and macro names.

True

False   

QUESTION 23

namespaces are guaranteed to be unique.

True

False   

QUESTION 24

When passing a non-const argument to a const function, the const_cast operator should be used to cast away the "const-ness" of the function.

True

False   

QUESTION 25

namespaces cannot have namespaces as members.

True

False

QUESTION 26

What does the term hardware refer to?

The relative difficulty of programming

The physical components that a computer is made of

The way a computer's storage space is organized

The logical flow of instructions

QUESTION 27

An Integrated Development Environment typically consists of:

A text editor

A compiler

A debugger

All of the above

QUESTION 28

The programming process consists of several steps, which include:

Input, Processing, and Output

Key Words, Operators, and Punctuation

Design, Creation, Testing, and Debugging

Syntax, Logic, and Error Handling

QUESTION 29

Programmer-defined names of memory locations that may hold data are:

Operators

Variables

Syntax

Operands

QUESTION 30

The computer's main memory is commonly known as:

The hard disk

The floppy disk

RAM

Secondary storage

QUESTION 31

Which of the following is a preprocessor directive?

pay = hours * rate;

cin >> rate;

int main()

#include <iostream>

QUESTION 32

In a C++ program, two slash marks ( // ) indicate:

The end of a statement

The beginning of a comment

The end of the program

The beginning of a block of code

QUESTION 33

What is the output of the following statement?

cout << 4 * (15 / (1 + 3)) << endl;

15

12

63

72

QUESTION 34

How would you consolidate the following declaration statements into one statement?

int x = 7;

int y = 16;

int z = 28;

int x = 7; y = 16; z = 28;

int x = 7 y = 16 z = 28;

int x, y, z = 7, 16, 28

int x = 7, y = 16, z = 28;

QUESTION 35

Look at the following program and answer the question that follows it.

1

// This program displays my gross wages.

2

// I worked 40 hours and I make $20.00 per hour.

3

#include <iostream>

4

using namespace std;

5

6

int main()

7

{

8

int hours;

9

double payRate, grossPay;

10

11

hours = 40;

12

payRate = 20.0;

13

grossPay = hours * payRate;

14

cout << "My gross pay is $" << grossPay << endl;

15

return 0;

16

}

Which line(s) in this program cause output to be displayed on the screen?

13 and 14

8 and 9

14

13

QUESTION 36

What is the value stored at x, given the statements:

int x;

x = 3 / static_cast<int>(4.5 + 6.4);

.3

0

0275229

3.3

QUESTION 37

You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?

cin << length, width, height;

cin.get(length, width, height);

cin >> length >> width >> height;

cin >> length, width, height;

QUESTION 38

Which statement is equivalent to the following?

number += 1;

number = number + 1;

number + 1;

number = 1;

None of the above

QUESTION 39

This operator represents the logical AND.

++

| |

&&

@

QUESTION 40

In C++ the = operator indicates:

equality

assignment

subtraction

negation

QUESTION 41

What will the following segment of code output if 11 is entered at the keyboard?

int number;

cin >> number;

if (number > 0)

cout << "C++";

else

cout << "Soccer";

cout << " is ";

cout << "fun" << endl;

C++ is fun

Soccer is fun

C++

C++fun

QUESTION 42

The while loop has two important parts: an expression that is tested for a true or false value, and:

a statement or block that is repeated as long as the expression is true

a statement or block that is repeated only if the expression is false

one line of code that is repeated once, if the expression is true

a statement or block that is repeated once, if the expression is true

QUESTION 43

This is a collection of statements that performs a specific task.

infinite loop

variable

constant

function

QUESTION 44

A function is executed when it is

defined

prototyped

declared

called

QUESTION 45

Given the following function definition

void calc (int a, int& b)

{

int c;

c = a + 2;

a = a * 3;

b = c + a;

}

What is the output of the following code fragment that invokes calc?

(All variables are of type int)

x = 1;

y = 2;

z = 3;

calc(x, y);

cout << x << " " << y << " " << z << endl;

1 2 3

1 6   3

3   6 3

1 14   9

QUESTION 46

A ___________ variable is declared outside all functions.

local

global

floating-point

counter

QUESTION 47

Which of the following is a valid C++ array definition?

int array[0];

float $payments[10];

void numbers[5];

int array[10];

QUESTION 48

A ________ algorithm is a method of locating a specific item of information in a larger collection of data.

sort

search

standard

linear

QUESTION 49

The statement:

   int *ptr;

has the same meaning as

int ptr;

*int ptr;

int ptr*;

int* ptr;

QUESTION 50

Which statement opens a file and links it to a file stream object?

open(aFile) = link(anObject);

file.open("c:\filename.txt");

linkstream("filename.txt");

link(open(filename.txt"));

A.

can potentially result in changes to the structure's members.

B.

guarantees not to result in changes to the structure's members.

C.

will always change the structure's members.

D.

All of the above

Explanation / Answer

Q1. Passing a structure as a constant reference parameter to a function:        

Answer: guarantees not to result in changes to the structure's members.

Q2.Before a structure can be used, it must be

Answer: Before a structure can be used, it must be declared because we have to use variable of type struct.

Q3. This allows you to access structure members.

Answer: Dot operator allows you to access structure members.

Q4. Which of the following statements outputs the value of the gpa member of element 1 of the student array?

Answer: cout << student[1].gpa;

Q5. Look at the following structure declaration.

struct Employee

{

string name;

int idNum;

};

In this declaration, Employee is

Answer: a member

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote