COP2220 FINAL EXAM

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

Three primary activities of a program are:

Input, Processing, and Output

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

cin >> length >> width >> height;

Which statement will read a string into the following char array? char names[20];

cin >> names;

The _________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.

cin object

This stream manipulator forces cout to print the digits in fixed-point notation.

fixed

To allow file access in a program, you must #include this header file.

fstream

This is a statement that causes a function to execute.

function call

A ___________ variable is declared outside all functions.

global

A function __________ eliminates the need to place a function definition before all calls to the function.

prototype

When used as parameters, these types of variables allow a function to access the parameter's original argument.

reference

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

scope

This manipulator is used to establish a field width for the value immediately following it.

setw

A character literal is enclosed in ________ quotation marks, whereas a string literal is enclosed in ________ quotation marks.

single, double

This is a dummy function that is called instead of the actual function it represents.

stub

Which of the following best describes an operator?

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

For every opening brace in a C++ program, there must be a:

Closing brace

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

Compilers

This step will uncover any syntax errors in your program.

Compiling

The ________ decodes an instruction and generates electrical signals.

Control Unit

These types of arguments are passed to parameters automatically if no argument is provided in the function call.

Default

The programming process consists of several steps, which include:

Design, Creation, Testing, and Debugging

EXIT_FAILURE and __________ are named constants that may be used to indicate success or failure when the exit() function is called.

EXIT_SUCCESS

The character array company[12] can hold

Eleven characters and the null terminator

During which stage does the central processing unit retrieve from main memory the next instruction in the sequence of program instructions?

Fetch

The computer's main memory is commonly known as:

RAM

This is used to mark the end of a complete C++ programming statement.

Semicolon

The statements written by the programmer are called:

Source code

This is a complete instruction that causes the computer to perform some action

Statement

In programming terms, a group of characters inside a set of quotation marks is called a:

String literal

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

The beginning of a comment

When the final value of an expression is assigned to a variable, it will be converted to:

The data type of the variable

____________ must be included in any program that uses the cout object.

The header file iostream

In a function header, you must furnish

The name of the function, data type(s) of the parameters, data type of the return value

What does the term hardware refer to?

The physical components that a computer is made of

A variable declaration announces the name of a variable that will be used in a program, as well as:

The type of data it will be used to hold

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

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

Variables

_____________ represent storage locations in the computer's memory.

Variables

Which character signifies the beginning of an escape sequence?

\

A loop that is inside another loop is called:

a nested loop

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

The statements in the body of a while loop may never be executed, whereas the statements in the body of a do-while loop will be executed:

at least once

A variable whose value can be either true or false is of this data type.

bool

Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function.

call

A function is executed when it is

called

Which data type typically requires only one byte of storage?

char

This reads an entire line of text, until the [Enter] key is pressed.

cin.getline()

The function, pow(x, 5.0), requires this header file.

cmath

This statement may be used to stop a loop's current iteration and begin the next one.

continue

This is a variable that is regularly incremented or decremented each time a loop iterates.

counter

The ______ is/are used to display information on the computer's screen.

cout object

A(n) _________ argument is passed to a parameter when the actual argument is left out of the function call.

default

A function __________ contains the statements that make up the function.

definition

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

definition

It is a good programming practice to ____________ your functions by writing comments that describe what they do.

document

The _____ causes the contents of another file to be inserted into a program.

#include directive

These are operators that add and subtract one from their operands.

++ and --

What is the value stored at x, given the statements: int x; x = 3 / static_cast<int>(4.5 + 6.4);

0

What is the output of the following code segment? n = 1; while (n <= 5) { cout << n << " "; n++; }

1 2 3 4 5

What is the output of the following statement? cout << 4 + 8;

12

In the following C++ statement, what will be executed first according to the order of precedence. result = 6 - 3 * 2 + 7 - 10 / 2 ;

3 * 2

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

39

How many characters does the string, "John Doe" require so it can be stored in memory properly?

7

Which line in the following program will cause a compiler error? 1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 const int MY_VAL = 77; 7 MY_VAL = 99; 8 cout << MY_VAL << endl; 9 return 0; 10 }

7

Look at the following statement. while (x++ < 10) Which operator is used first?

<

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

>>, <<

An Integrated Development Environment typically consists of:

A compiler, a text editor, and a debugger.

Which of the following statements about global variables is true?

A global variable can have the same name as a variable that is declared locally within a function.

What statement best describes a variable and its primary purpose?

A variable is a named storage location in the computer's memory used for holding a piece of information.

Which is true about the following statement? cout << setw(4) << num4 << " ";

It allows four spaces for the value in the variable num4.

Of the following, which is a valid C++ identifier?

June1997, ___department, _employee_number, and myExtraLongVariableName are all valid identifiers

Words that have a special meaning and may be used only for their intended purpose are known as:

Key Words

These are data items whose values do not change while the program is running.

Literals

In memory, C++ automatically places a ___________ at the end of string literals.

Null terminator

A statement that starts with a # is called a:

Preprocessor directive

A(n) ____________ is a set of instructions that the computer follows to solve a problem.

Program

This function causes a program to terminate, regardless of which function or control mechanism is executing.

exit()

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

null statement

To write data to a file, you define an object of this data type.

ofstream

The do-while loop is a __________ loop that is ideal in situations where you always want the loop to iterate at least once.

post-test

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

update

You may define a __________ in the initialization expression of a for loop.

variable

A set of well-defined steps for performing a task or solving a problem is known as a(n):

Algorithm

If you are reading data from a keyboard and you wanted the computer to recognize the space, tab, or Enter key as the delimiter to separate two input values, you would use the _______ object.

cin

This means to increase a value by one.

increment

Something within a while loop must eventually cause the condition to become false, or a(n) __________ results.

infinite loop

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

initialization

The numeric data types in C++ can be broken into two general categories:

integer and floating point

In any program that uses the cin object, you must include the ___________.

iostream header file

The while loop contains 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

This type of variable is defined inside a function and is not accessible outside the function.

local

This is a control structure that causes a statement or group of statements to repeat.

loop

If a function is called more than once in a program, the values stored in the function's local variables do not _________ between function calls.

persist

The while loop is this type of loop.

post-test

When the increment operator precedes its operand, as in ++num1, the expression is in this mode.

prefix

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

prefix increment


Ensembles d'études connexes

Hole's Human Anatomy & Physiology Companion Website: Chapter 1: Introduction to Human Anatomy and Physiology: Pre-Test Quiz

View Set

CISSP | Test Questions | Domain 8 | Business Continuity & Disaster Recovery Planning

View Set

identify the role responsible for the following preoperative responsibilities

View Set

IC3 - Lesson 13: Looking at the Internet

View Set

N126 HESI - Elsevier Adaptive Quizzing #4

View Set

Unit 2 Assuming most crimes involve violence because the media generally reports stories on sexual assault, robberies and homicide is an example of the _____ heuristic. vividness matching Correct! availability Assessment

View Set