CSC final exam review

¡Supera tus tareas y exámenes ahora con Quizwiz!

The following program displays __________. #include <iostream> using namespace std; int main() { cout << "A"; cout << "B"; return 0; }

AB

A(n) ________ is information that is passed to a function, and a(n) ________ is information that is received by a function.

Argument, parameter

Unlike regular variables, ________ can hold multiple values.

Arrays

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

At least once

A block of code is enclosed inside __________.

Braces

A statement that causes a loop to terminate early is

Break

The _______ is the brain of a computer.

CPU

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

Call

Given the following switch statement, which case is correctly written? switch (x) { case 1: cout << "One"; return 0; case 2: cout << "Two"; exit; case 3: cout << "Three"; break; case 4: cout << "Four"; endswitch; }

Case 3

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

Cin object

The first step in writing a program is to

Clearly define what the program is to do

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

Closes a file

A ________ is a software program that translates the source code (.cpp file) into machine language

Compiler

To improve readability and maintainability, you should declare _________ instead of using literal values such as 3.14159

Constants

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

Counter

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

Defenition

The ________ loop is ideal in situations where you want the loop to iterate at least once.

Do-while

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

Document

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 the ________ data type.

Ofstream

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

One

A function can have no parameters, one parameter, or many parameters and can return ________ value(s).

Only one

A file must be ________ before data can be written to or read from it.

Opened

The _______ is a program that manages and controls a computer and it's attached devices.

Operating System

This statement causes a function to end.

Return

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

Subscript

To access an array element, use the array name and the element's ________.

Subscript

Not equal

!=

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

#include <fstream>

And

&&

Suppose x=10 and y=10 what is x after evaluating the expression (y >= 10) || (x++ > 10).

10

Given the following segment of code, what is the value of " z "? x = 10; y = 2; z = pow(x, y);

100

What is the last legal subscript that can be used with the following array? int values[5];

4

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

5

What will the value of the variable 'x' be when displayed? // Example Program #include <iostream> using namespace std; int main() { int x; float y; y = 3.14591; x = y * 2; cout << x; system("PAUSE"); return 0; }

6

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

7

The "less than or equal to" comparison operator is __________.

<=

Equal

==

The __________ is an equality (or comparison) operator.

==

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

>>,<<

An array can easily be stepped through by using a

A for loop

Which of the following causes a function to execute?

A function call

An array can store a group of values, but the values must be

The same data type

A bit is a binary digit, either a 0 or 1.

True

A value is stored in a variable with an assignment statement.

True

The cin << statement will stop reading input when it encounters a newline character.

True

This program will have a compiler error? (T/F) // Example Program #include <iostream> using namespace std; int main() { int a = 1; cout << A; system("PAUSE"); return 0;

True

When compiling a program, the compiler changes your .cpp file into machine language (binary).

True

When typing your source code into the computer, you should be careful since most of your C++ instructions, header files, and variable names are case sensitive.

True

________ functions may have the same name as long as their parameter lists are different.

Two or more

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

Update

A named storage location in the computer's memory that holds a piece of information is a(n):

Variable

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

Variable

The ________ loop is a good choice when you do not want the loop to iterate if the condition is FALSE in the beginning.

While

To assign a value 1 to variable x, you write

X=1;

Which of these statements will not increase the value of x by 1?

X==1;

To add 1 to variable x, you write:

X=x+1;

The two important parts of a while loop are the 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

Why do computers use zeros and ones?

because digital devices have two stable states and it is natural to use one state for 0 and the other for 1 (a state of ON or OFF)

Which of the following statement prints smith\exam1\test.txt?

cout << "smith\exam1\test.txt";

While line of code has an error in it: // Example Program #include <iostream> using namespace std; int main() { int test1=0; cout >> "Please enter a number: "; cin >> test1; cout << "You entered " << num1 << "."; system("PAUSE"); return 1; }

cout >> "Please enter a number: ";

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

int scores [25];

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

int sizes[10];

Assuming outFile is a file stream object and number is a variable, which statement writes the contents of number to the file associated with outFile?

outFile << number;

The do-while loop is considered

post-test loop

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

prefix increment

The while loop is a ________ loop.

pretest

The two methods used by C++ to write computer programs are:

procedural programming, object-oriented programming

Given the following declaration, where is the value 77 stored in the scores array? int scores[] = {83, 62, 77, 97, 86}

scores[2]

This is a set of rules that must be followed when constructing a program:

syntax

Why do we declare variables?

the compiler needs to know what each variable will store & the program must reserve memory space for each variable

Or

II

As a rule of style, when writing an if statement you should indent the conditionally-executed statements.

+=

The file extension of a C++ source code file is:

.cpp

Suppose x is 1. What is x after x--?

0

A character is stored in __________.

1 byte

Subscript numbering in C++

Begins with zero

The individual values contained in an array are known as

Elements

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

Exit()

What is the output of the following code? bool even = false; cout << (even ? "true" : "false") << endl;

False

Which of the following variable types should be used to store the value 0.5?

Float

The ________ loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop.

For

A collection of statements that performs a specific task is a(n)

Function

A ________ variable is declared outside all functions.

Global

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

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

Initialization list

Good Documentation & Programming Style is important, because ______________.

It makes your program easier to read, and easier to troubleshoot

Which of the following justifies the output to the left?

Left

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

Local

Mistakes that cause a running program to produce incorrect results are called:

Logic Errors

A loop that is inside another loop is called a(n)

Nested loop

Which of the following code displays the area of a circle if the radius is positive.

if (radius > 0) cout << radius * radius * 3.14159;

This means to increase a value:

increment

Arrays must be ________ at the time they are ________.

initialized, declared

Three primary activities of a program are:

input, processing, output


Conjuntos de estudio relacionados

EMPIRICAL FORMULA OF COPPER OXIDE: Late Nite Labs

View Set

SSC101- All Chap- ko trắc nghiệm, SSC101- có trắc nghiệm

View Set

МОВА ДIЛОВИХ ПАПЕРІВ

View Set

Chapter Reviews- Chapter 1: Basic Concepts

View Set

CHAPTER 3. Doing Business in Global Markets

View Set