COP1334C

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which of the following is evaluated first, given the expression: A && B || C && !D

!D

To allow file access in a program, you must use ________ in the header file.

#include fstream

What will the following code display? int numbers[4] = {99, 87}; cout << numbers[3] << endl;

0

When a relational expression is FALSE, it has the value

0.

What is the value of average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0;

4.0

What will the following code display? int number = 6; int x = 0; x = --number; cout << x << endl;

5

What will the following code display? int numbers[] = {99, 87, 66, 55, 101}; cout << numbers[3] << endl;

55

What will the following code display? int number = 6; cout << ++number << endl;

6

What will the following code display? int number = 6; number++; cout << number << endl;

7

How many characters will the following statement read into the variable myString? cin >> setw(10) >> myString;

9

What will the following code display? cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl;

Four score and seven years ago

In a for statement, this expression is executed only once:

Initialization

Three primary activities of a program are:

Input, processing, output

Which line in the following program will cause a compiler error? 1 #include <iostream> 2 using namespace std; 3 int main () 4 { 5 int number = 5; 6 if (number >= 0 && <=100) 7 cout << "passed. \n"; 8 else 9 cout << "failed. \n"; 10 return 0; 11 }

Line 6

Which line in the following program will cause a compiler error? #include <iostream> using namespace std; int main() { const int MY_VAL = 77; MY_VAL = 99; cout << MY_VAL << endl; return 0; }

Line 7

What will the following code display? cout << "Monday"; cout << "Tuesday"; cout << "Wednesday";

MondayTuesdayWednesday

What will the following code display? int numbers[] = {99, 87, 66, 55, 101}; for (int i = 1; i < 4; i++) cout << numbers[i] << " ";

Nothing. This code has an error.

A two-dimensional array can have elements of ________ data type(s).

One

This operator increments the value of its operand and then uses the value in context.

Prefix increment

A volatile type of memory that is used for temporary storage is

RAM

If you place a semicolon after the statement: if (x < y)

The compiler will interpret the semicolon as a null statement

Which of the following will allow you to access structure members?

The dot operator

What will be displayed after the following statements execute? int num1 = 5; int num2 = 3; cout << "The result is " << (num1 * num2 + 10) << endl;

The result is 25

What is the value of the following expression? true && !false

True

What is the value of the following expression? true || false

True

If Circle is a structure tag, then the following statement can be the header line for a function that ________. Circle doSomething(Circle c2)

takes a Circle structure as a parameter, does something, and returns a Circle structure

Which of the following functions will return the value of x, rounded to the nearest whole number?

round(x)

A variable's ________ is the part of the program that has access to the variable.

scope

An Integrated Development Environment (IDE) typically consists of

text editor A compiler A debugger

The two parts of the CPU are

the Control Unit and the Arithmetic and Logic Unit.

Programs are normally stored in ________ and loaded into main memory as needed.

secondary storage

You can control the number of significant digits in your output with the ________ manipulator.

setprecision

This manipulator is used to establish a field width for the value that follows it:

setw

Character constants in C++ are always enclosed in

single quotation marks ( ' ' )

Computer programs are also known as

software

When a programmer saves to a file the statements he or she writes to create a program, these statements are

source code

By using the same ________, you can build relationships between data stored in two or more arrays.

subscript

This statement uses the value of a variable or expression to determine where the program will branch to.

switch

An element of a two-dimensional array is referred to by

the row subscript of the element followed by the column subscript of the element.

At the heart of a computer is its central processing unit. The CPU's job is:

to fetch instructions To carry out the operations commanded by the instructions To produce some outcome or resultant information

When C++ is working with an operator, it strives to convert operands to the same type. This is known as

type conversion

A for statement contains three expressions: initialization, test, and

update

Which part of the following line is ignored by the compiler? double userName = "janedoe"; // user's name is janedoe

user's name is janedoe

You must have a ________ for every variable you intend to use in a program.

variable definition

The following statement ________. bookList[2].publisher[3] = 't';

will store the character 't' in the fourth element of the publisher member of bookList[2]

Whereas < is called a relational operator, x < y is called a(n)

relational expression

How many elements does the following array have? int values[1000];

1000

What is the value of cube after the following code executes? double cube, side; side = 5.0; cube = pow(side, 3.0);

125.0

What is the value of cookies after the following statements execute? int number = 38, children = 4, cookies; cookies = number % children;

2

How many times will the following loop display "Hello world!"? for (int i = 0; i < 20; i++) cout << "Hello world" << endl;

20

How many times will the following loop display "Looping!"? for (int i = 20; i > 0; i--) cout << "Looping!" << endl;

20

What is the value of result after the following code executes? int a = 60; int b = 15; int result = 10; if (a = b) result *= 2;

20

What will the following code display? int x = 0; for (int count = 0; coant < 3; count++) x += count; cout << x << endl;

3

What is the value of number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3;

39

What is the output of the following code? int w = 98; int x = 99; int y = 0; int z = 1; if (x >= 99) { if (x < 99) cout << y << endl; else cout << z << endl; } else { if (x == 99) cout << x << endl; else cout << w << endl; }

98

Which value can be entered to cause the following code segment to display the message "That number is acceptable"? int number; cin >> number; if (number > 10 && number < 100) cout << "That number is acceptable.\n"; else cout << "That number is not acceptable.\n";

99

The ________ operator always follows the cin object, and the ________ operator follows the cout object.

>>,<<

Select all that apply. Which of the following statements is(are) TRUE about named constants?

A named constant is defined using the const qualifier The value of a named constant cannot be changed while the program is running. The content of a named constant is read-only.

Which of the following is an example of a C++ primitive data type?

All of these

Which of the following best describes an operator?

An operator allows you to perform operations on one or more pieces of data.

Assuming dataFile is a file stream object, the following statement: dataFile.close();

Closes a file

What is the output of the following code segment, if the user enters 90 for the score? cout << "Enter your test score: "; cin >> test_score; if (test_score < 60) cout << "You failed the test." << endl; if (test_score > 60) cout << "You passed the test." else cout << "You need to study harder next time." << endl;

You passed the test. You need to study harder next time.

Given the if/else statement: If (a < 5) b = 12; else d = 30; Which of the following performs the same operation?

a < 5 ? b = 12 : d = 30;

Given the following structure declaration, idNum is struct Employee { string name; int idNum; };

a member

Given the following structure declaration, Employee is struct Employee { string name; int idNum; };

a tag

Data types that are created by the programmer are known as

abstract data types (ADTs).

Unlike regular variables, ________ can hold multiple values.

arrays

Subscript numbering in C++

begins with zero

A file ________ is a small holding section of memory that file-bound information is first written to.

buffer

When a structure is passed ________ to a function, its members are NOT copied.

by reference

A structure ________ contain members of the same data type.

can

Which of the following will allow the user to input the values 15 and 20 and have them stored in variables named base and height, respectively?

cin >> base >> height;

For every opening brace ({) in a C++ program, there must be a

closing brace. Which data type typically requires only one byte of storage? @ char

________ are used to translate each source code instruction into the appropriate machine language instruction.

compilers

An array's size declarator must be a ________ with a value greater than ________.

constant integer expression, zero

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

cout << student[1].gpa;

To use the rand()function, you must include the ________ header file.

cstdlib

If you intend to place a block of statements within an if statement, you must place ________ around the block.

curly braces { }

Before a structure can be used, it must be

declared

The term that refers to the programmer reading the program from the beginning and stepping through each statement is

desk checking.

Which of the following defines a double-precision floating-point variable named payCheck?

double payCheck;

Which of the following assigns a value to the hourlyWage member of employee[2]?

employee[2].hourlyWage = 75.00;

A character literal is ________, whereas a string literal is ________

enclosed in single quotation marks, enclosed in double quotation marks

The CPU's control unit retrieves the next instruction in a sequence of program instructions from main memory in the ________ stage.

fetch

If you want a user to enter exactly 20 values, which loop would be the best to use?

for

Passing a structure as a constant reference parameter to a function

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

A debugging process where you, the programmer, pretend you are a computer and step through each statement while recording the value of each variable at each step is known as

hand tracing.

Which statement allows you to properly check the char variable code to determine whether it is equal to a C, and then output This is a check?

if (code == C) cout << "This is a check" << endl;

This following statement shows an example of ________. int grades][ ] = {100, 90, 99, 80};

implicit array sizing

A computer stores a program while it is running

in main memory

A(n) ________ can be used to specify the starting values of an array.

initialization list

The data type used to declare variables that can hold real numbers is

int

This manipulator causes the field to be left justified, with padding spaces printed to the right:

left

It is ________ to pass an argument to a function that contains an individual array element, such as scores[3].

legal in C++

Which of the following statements correctly assigns the character M to the variable named letter?

letter = 'M';

A good reason to pass a structure as a constant reference is to prevent changes to the structure's members. A function ________ return a structure.

may

To pass an array as an argument to a function, pass the ________ of the array.

name

If you place a semicolon after the test expression in a while loop, it is assumed to be a(n)

null statement

The ________ is automatically appended to a character array when it is initialized with a string constant.

null terminator

To write read data from a file, you define an object of the ________ data type.

ofstream

Characters or symbols that perform operations on one or more operands are

operators.

A computer monitor is a type of

output device

A statement that starts with a hashtag (or pound) symbol (#) is called a

preprocessor directive.


Ensembles d'études connexes

French Revolution/Nepoleonic Era

View Set

Management of Information Security Chapter 8

View Set

Introduction to Nutrition HLTH1010 - Final Milestone

View Set