CSIS 123 Midterm

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

False

C++ programs have always been portable from one compiler to another.

True

Information stored in main memory must be transferred to some other device for permanent storage.

alpha = beta; beta = beta + 1;

Suppose that alpha and beta are int variables. The statement alpha = beta++; is equivalent to the statement(s) ____.

True

Suppose that sum is an int variable. The statement sum += 7; is equivalent to the statement sum = sum + 7;

False

The devices that feed data and programs into computers are called output devices.

16

The length of the string "computer science" is ____.

object program

The machine language version of the high-level language program is called a(n) ____________________.

True

The maximum number of significant digits in values of the double type is 15.

four

The memory allocated for a float value is ____ bytes.

Digital or digital

____________________ signals represent information with a sequence of 0s and 1s.

double

An example of a floating point data type is ____.

Sunny Day

Choose the output of the following C++ statement: cout << "Sunny " << '\n' << "Day " << endl;

alpha = beta; beta = beta - 1;

Suppose that alpha and beta are int variables. The statement alpha = beta--; is equivalent to the statement(s) ____.

False

A comma is also called a statement terminator.

simple

A data type is called ____________________ if the variable or named constant of that type can store only one value at a time.

linker

A program called a(n) ____ combines the object program with the programs from libraries.

compiler

A program called a(n) ____ translates instructions written in high-level languages into machine code.

assembler

A program called a(n) ____________________ translates the assembly language instructions into machine language.

loader

A program that loads an executable program into main memory is called a(n) ____.

binary

A sequence of 0s and 1s is sometimes referred to as ____________________ code.

byte

A sequence of eight bits is called a ____.

algorithm

A step-by-step problem-solving process in which a solution is arrived at in a finite amount of time is called a(n) ____.

object

A(n) ____ consists of data and the operations on those data.

subprogram or sub program or sub-program or function or modlue

A(n) ____________________ is a collection of statements, and when it is activated, or executed, it accomplishes something.

variable

A(n) ____________________ is a memory location whose contents can be changed.

string

A(n) ____________________ is a sequence of zero or more characters.

relational

A ____________________ operator allows you to make comparisions in a program.

True

A compound statement functions as if it was a single statement.

True

A control structure alters the normal sequential flow of execution in a program.

switch

A(n) ____________________ structure does not require the evaluation of a logical expression.

alpha = 17, ch = 'A'

Suppose that alpha is an int variable and ch is a char variable and the input is: 17 A What are the values after the following statements execute? cin >> alpha; cin >> ch;

300

Suppose that alpha, beta, and gamma are int variables and the input is: 100 110 120 200 210 220 300 310 320 What is the value of gamma after the following statements execute? cin >> alpha; cin.ignore(100, '\n'); cin >> beta; cin.ignore(100,'\n'); cin >> gamma;

X

Suppose that ch1 and ch2 are char variables and the input is: WXYZ What is the value of ch2 after the following statements execute? cin >> ch1; ch2 = cin.peek(); cin >> ch2;

W

Suppose that ch1 and ch2 are char variables and the input is: WXYZ What is the value of ch2 after the following statements execute? cin.get(ch1); cin.putback(ch1); cin >> ch2;

ch1 = 'A', ch2 = ' ', alpha = 18

Suppose that ch1 and ch2 are char variables, alpha is an int variable, and the input is: A 18 What are the values after the following statement executes? cin.get(ch1); cin.get(ch2); cin >> alpha;

'C'

Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: A B C Choose the value of ch3 after the following statement executes: cin >> ch1 >> ch2 >> ch3;

'B'

Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: A B C What is the value of ch3 after the following statements execute? cin.get(ch1); cin.get(ch2); cin.get(ch3);

outFile.open("outputData.out");

Suppose that outFile is an ofstream variable and output is to be stored in the file outputData.out. Which of the following statements opens the file outputData.out and associates outFile to the output file?

1565.683 85.7800 123.98

Suppose that x = 1565.683, y = 85.78, and z = 123.982. What is the output of the following statements? cout << fixed << showpoint; cout << setprecision(3) << x << ' '; cout << setprecision(4) << y << ' ' << setprecision(2) << z << endl;

25.67 356.88 7623.97

Suppose that x = 25.67, y = 356.876, and z = 7623.9674. What is the output of the following statements? cout << fixed << showpoint; cout << setprecision(2); cout << x << ' ' << y << ' ' << z << endl;

55.680 476.859 23.82

Suppose that x = 55.68, y = 476.859, and z = 23.8216. What is the output of the following statements? cout << fixed << showpoint; cout << setprecision(3); cout << x << ' ' << y << ' ' << setprecision(2) << z << endl;

This statement results in input failure

Suppose that x and y are int variables, ch is a char variable, and the input is: 4 2 A 12 Choose the values of x, y, and ch after the following statement executes: cin >> x >> ch >> y;

x = 28, y = 32, z = 0.6

Suppose that x and y are int variables, z is a double variable, and the input is: 28 32.6 12 Choose the values of x, y, and z after the following statement executes: cin >> x >> y >> z;

cin >> x >> y;

Suppose that x and y are int variables. Which of the following is a valid input statement?

x = 10, y = 20.7

Suppose that x is an int variable and y is a double variable and the input is: 10 20.7 Choose the values after the following statement executes: cin >> x >> y;.

ch = '276', x = '.'

Suppose that x is an int variable, ch is a char variable, and the input is: 276. Choose the values after the following statement executes: cin >> ch >> x;

short circuit evaluation

The term ____________________ describes a process in which the computer evaluates a logical expression from left to right and stops as soon as the value of the expression is known.

false

The value of the expression 6 < 5 || 'g' > 'a' && 7 < 4 is ____________________.

true

The value of the expression 7 + 8 <= 15 is ____________________.

pseudocode

To develop a program, you can use an informal mixture of C++ and ordinary language, called ____.

break

To output results correctly, the switch structure must include a(n) ____________________ statement after each cout statement, except the last cout statement.

iomanip

To use a parameterized stream manipulator in a program, you must include the header file ____________________.

iomanip

To use the manipulator setprecision, the program must include the header file ____________________.

less than or equal to

What does <= mean?

35 45 10

What is the output of the following C++ code? int x = 35; int y = 45; int z; if (x > y) z = x + y; else z = y - x; cout << x << " " << y << " " << z << endl;

2

What is the output of the following C++ code? int x = 55; int y = 5; switch (x % 7) { case 0: case 1: y++; case 2: case 3: y = y + 2; case 4: break; case 5: case 6: y = y - 3; } cout << y << endl;

13

What is the output of the following code fragment if the input value is 4? int num; int alpha = 10; cin >> num; switch (num) { case 3: alpha++; break; case 4: case 6: alpha = alpha + 3; case 8: alpha = alpha + 4; break; default: alpha = alpha + 5; } cout << alpha << endl;

section 1

What is the output of the following code? char lastInitial = 'A'; switch (lastInitial) { case 'A': cout << "section 1" <<endl; break; case 'B': cout << "section 2" <<endl; break; case 'C': cout << "section 3" <<endl; break; case 'D': cout << "section 4" <<endl; break; default: cout << "section 5" <<endl; }

section 5

What is the output of the following code? char lastInitial = 'S'; switch (lastInitial) { case 'A': cout << "section 1" <<endl; break; case 'B': cout << "section 2" <<endl; break; case 'C': cout << "section 3" <<endl; break; case 'D': cout << "section 4" <<endl; break; default: cout << "section 5" <<endl; }

*

What is the output of the following code? if (6 > 8) { cout << " ** " << endl ; cout << "****" << endl; } else if (9 == 4) cout << "***" << endl; else cout << "*" << endl;

123456789012345678901234567890 ####Mickey Donald*****Goofy

What is the output of the following statements? cout << "123456789012345678901234567890" << endl cout << setfill('#') << setw(10) << "Mickey" << setfill(' ') << setw(10) << "Donald" << setfill('*') << setw(10) << "Goofy" << endl;

12345678901234567890 ***18**Happy**Sleepy

What is the output of the following statements? cout << setfill('*'); cout << "12345678901234567890" << endl cout << setw(5) << "18" << setw(7) << "Happy" << setw(8) << "Sleepy" << endl;

4

What is the value of x after the following statements execute? int x; x = (5 <= 3 && 'A' < 'F') ? 3 : 4

nested

When one control statement is located within another, it is said to be ____.

true

When reading data into a char variable, after skipping any leading whitespace characters, the extraction operator >> finds and stores only the next character; reading stops after a single character.

false

When the computer is turned off, everything in secondary memory is lost.

main memory

When the power is switched off, everything in ____ is lost.

ignore

When you want to process only partial data, you can use the stream function ____ to discard a portion of the input.

10 < x && x < 20

Which of the following expressions correctly determines that x is greater than 10 and less than 20?

==

Which of the following is a relational operator?

char

Which of the following is a reserved word in C++?

!=

Which of the following is the "not equal to" relational operator?

\n

Which of the following is the newline character?

!

Which of the following operators has the highest precedence?

=

Which of the following operators has the lowest precedence?

if (x = 5)

Which of the following will cause a logical error if you are attempting to compare x to 5?

application programs or applications

Word processors, spreadsheets, and games are examples of ____________________.

#define NDEBUG

You can disable assert statements by using which of the following?

unsetf

You can disable the manipulator left by using the stream function ____________________.

true

You can use the function getline to read a string containing blanks.

setfill

____ is a parameterized stream manipulator.

Programming or programming

____________________ is the process of planning and creating a program.

False

A mixed arithmetic expression contains all operands of the same type.

False

An operator that has only one operand is called a unique operator.

mnemonics

Assembly language uses easy-to-remember instructions called ____________________.

object-oriented or object oriented or OO or oo or OOD or ood

In ____________________ design, the final program is a collection of interacting objects.

whitespaces or whitespace or white spaces or white space

In a C++ program, ____________________ are used to separate special symbols, reserved words, and identifiers.

one = 10.5, two = 30.6

In a C++ program, one and two are double variables and input values are 10.5 and 30.6. After the statement cin >> one >> two; executes, ____.

preprocessor

In a C++ program, statements that begin with the symbol # are called ____________________ directives.

objects

In object-oriented design, the first step in the problem-solving process is to identify the components called ____________________, which form the basis of the solution, and to determine how they interact with one another.

alpha = 50

Suppose that alpha and beta are int variables and alpha = 5 and beta = 10. After the statement alpha *= beta; executes, ____.

beta = beta + 1; alpha = beta;

Suppose that alpha and beta are int variables. The statement alpha = ++beta; is equivalent to the statement(s) ____.

beta = beta - 1; alpha = beta;

Suppose that alpha and beta are int variables. The statement alpha = --beta; is equivalent to the statement(s) ____.

2

Suppose that count is an int variable and count = 1. After the statement count++; executes, the value of count is ____.

sum = 15

Suppose that sum and num are int variables and sum = 5 and num = 10. After the statement sum += num executes, ____.

False

The device that stores information permanently (unless the device becomes unusable or you change the information by rewriting it) is called primary storage.

input

The devices that feed data and programs into computers are called ____ devices.

13

The expression static_cast<int>(6.9) + static_cast<int>(7.9) evaluates to

9

The expression static_cast<int>(9.9) evaluates to ____.

True

The maximum number of significant digits in float values is up to 6 or 7.

analyzing the problem

To develop a program to solve a problem, you start by ____.

True

To develop a program to solve a problem, you start by analyzing the problem.

implicit

When a value of one data type is automatically changed to another data type, a(n) ____________________ type coercion is said to have occurred.

Prompt lines

____ are executable statements that inform the user what to do.

Unicode

____ consists of 65,536 characters.

'A'

____ is a valid char value.

46259 (not 46,259 462.59 -32.00)

____ is a valid int value.

Application

____ programs perform a specific task.

Digital signals

____ represent information with a sequence of 0s and 1s.

High-level or high-level or High level or high level

___________________ languages include FORTRAN, COBOL, Pascal, C, C++, and Java.

Comments or comments

____________________ can be used to identify the authors of the program, give the date when the program is written or modified, give a brief explanation of the program, and explain the meaning of key statements in a program.

True

If a C++ arithmetic expression has no parentheses, operators are evaluated from left to right.

False

In C++, reserved words are the same as predefined identifiers.

class

In C++, the mechanism that allows you to combine data and operations on the data into a single unit is called a(n) ____________________.

named constant or constant

In C++, you can use a(n) ____________________ to instruct a program to mark those memory locations in which data is fixed throughout program execution.

128

The ASCII data set consists of ____________________ characters.

bit

The digit 0 or 1 is called a binary digit, or ____.

precision

The maximum number of significant digits is called the ____________________.

C

The programming language C++ evolved from ____.

1980s

The programming language C++ was designed by Bjarne Stroustrup at Bell Laboratories in the early ____.

token

The smallest individual unit of a program written in any language is called a(n) ____________________.

compiler

Consider the following C++ program. #include <iostream> using namespace std; int main() { cout << "Hello World " return 0; } In the cout statement, the missing semicolon in the code above will be caught by the ____.

Insertion Point 1

Consider the following code. // Insertion Point 1 using namespace std; const float PI = 3.14; int main() { //Insertion Point 2 float r = 2.0; float area; area = PI * r * r; cout << "Area = " << area <<endl; return 0; } // Insertion Point 3 In this code, where does the include statement belong?

structured

Dividing a problem into smaller subproblems is called ____ design.

memory cells

Main memory is an ordered sequence of items, called ____.

CPU

The ____ is the brain of the computer and the single most expensive piece of hardware in your personal computer.

operating system

The ____ monitors the overall activity of the computer and provides services.

syntax

The ____ rules of a programming language tell you which statements are legal, or accepted by the programming language.

operating system or OS

The ____________________ monitors the overall activity of the computer and provides services such as memory management, input/output activities, and storage management.

enumeration

The ____________________ type is C++ 's method for allowing programmers to create their own simple data types.

input, output, storage

The basic commands that a computer performs are ____, and performance of arithmetic and logical operations.

true

The basic commands that a computer performs are input (get data), output (display result), storage, and performance of arithmetic and logical operations.

False

The command that does the linking on Visual C++ 2010 Express and Visual Studio 2010 is Make or Remake.

int a,b,c;

The declaration int a, b, c; is equivalent to which of the following?

modular programming or top-down design or top down design or top-down or top down or bottom-up design or bottom up design or bottom-up or bottom up or stepwise refinement

The structured design approach is also known as ____________________.

gigabyte

The term GB refers to ____.

source program or source code or source

The term ____________________ is used to describe a program that has been written in a high-level language.

True

Suppose a = 5. After the execution of the statement ++a; the value of a is 6.

putback

The stream function ____________________ lets you put the last character extracted from the input stream by the get function back into the input stream.

relational

The symbol > is a(n) ____________________ operator.

2

Assume you have three int variables: x = 2, y = 6, and z. Choose the value of z in the following expression: z = (y / x > 0) ? x : y;.

predefined or pre defined or pre-defined

C++ comes with a wealth of functions, called ____________________ functions, that are written by other programmers.

classes

C++ has a special name for the data types istream and ostream. They are called ____________________.

fstream

C++ provides a header file called ____________________, which is used for file I/O.

inFile.open("progdata.dat");

Consider the following program segment. ifstream inFile; //Line 1 int x, y; //Line 2 ... //Line 3 inFile >> x >> y; //Line 4 Which of the following statements at Line 3 can be used to open the file progdata.dat and input data from this file into x and y at Line 4?

pass

Consider the following statements. int score; string grade; if (score >= 65) grade = "pass"; else grade = "fail"; If score is equal to 75, the value of grade is "____________________".

true

Entering a char value into an int variable causes serious errors, called input failure.

if

Every else must be paired with a(n) ____________________.

#include <cassert>

For a program to use the assert function, it must include which of the following?

false

If input failure occurs in a C++ program, the program terminates immediately and displays an error message.

False

If the expression in an assert statement evaluates to true, the program terminates.

False

In C++, !, &&, and || are called relational operators.

True

In C++, && has a higher precedence than ||.

False

In C++, both ! and != are relational operators.

member access

In C++, the dot is an operator called the ____ operator.

member access

In C++, the dot is an operator called the ____________________operator.

&&

In C++, the logical operator AND is represented by ____________________.

selection

In a ____ control structure, the computer executes particular statements depending on some condition(s).

false

In an output statement, each occurrence of endl advances the cursor to the end of the current line on an output device.

char

In the C++ statement, cin.get(u); u must be a variable of type ____________________.

false

In the statement cin >> x;, x can be a variable or an expression.

false

It is a good idea to redefine cin and cout in your programs.

iostream

Manipulators without parameters are part of the ____ header file.

cin.setf(ios::fixed);

On some compilers, the statements cin >> fixed; and cin >> scientific; might not work. In this case, you can use the statement ____________________ in place of cin >> fixed;.

cin.setf(ios::left);

On some compilers, the statements cin >> left; and cin >> right; might not work. In this case, you can use the statement ____________________ in place of cin >> left;.

fail

Once an input stream enters a(n) ____________________ state, all subsequent input statements associated with that input stream are ignored, and the computer continues to execute the program, which produces erroneous results.

!

Putting ____________________ in front of a logical expression reverses the value of that logical expression.

semantic

Putting a semicolon after the parentheses following the expression in an if statement (that is, before the statement) is a(n) ____________________ error.

True

Suppose P and Q are logical expressions. The logical expression P && Q is true if both P and Q are true.

false

Suppose found = true and num = 6. The value of the expression (!found) || (num > 6) is ____________________.

x = 15, ch = 'A', y = 73.2

Suppose that x is an int variable, y is a double variable and ch is a char variable and the input is: 15A 73.2 Choose the values after the following statement executes: Suppose that x is an int variable, y is a double variable and ch is a char variable and the input is: 15A 73.2 Choose the values after the following statement executes: cin >> x >> ch >> y;

x = 15, y = 76.3, z = 14

Suppose that x is an int variable, y is a double variable, z is an int variable, and the input is: 15 76.3 14 Choose the values after the following statement executes: cin >> x >> y >> z;

(x > 0) || ( x <= 0)

Suppose that x is an int variable. Which of the following expressions always evaluates to true?

true

Suppose x is 5 and y is 7. Choose the value of the following expression: (x != 7) && (x <= y)

associativity

The ____________________ of relational and logical operators is said to be from left to right.

silent killer

The appearance of = in place of == resembles a(n) ____.

three

The conditional operator ?: takes ____ arguments.

False

The expression (x >= 0 && x <= 100) evaluates to false if either x < 0 or x >= 100.

decision maker

The expression in an if statement is sometimes called a(n) ____.

false

The extraction operator >> skips only all leading blanks when searching for the next data in the input stream.

false

The following statements will result in input failure if the input values are not on a separate line. (Assume that x and y are int variables.) cin >> x; cin >> y;

peek

The function ____________________ returns the next character in the input stream; it does not remove the character from the input stream.

istream

The functions get, ignore, and so on are members of the data type ____________________.

setw

The manipulator ____________________ is used to output the value of an expression in a specific number of columns.

true

The number of input data extracted by cin and >> depends on the number of variables appearing in the cin statement.

True

The operators != and == have the same order of precedence.

False

The result of a logical expression cannot be assigned to an int variable, but it can be assigned to a bool variable.

istream

cin is called a(n) ____________________ object.

mainframe, midsize, and micro

Several categories of computers exist, such as ____.

long long

The memory space for a(n) ____________________ data value is 64 bytes.

3

The value of the expression 17 % 7 is ____.

3

The value of the expression 33/10, assuming both values are integral data types, is ____.

False

When you compile your program, the compiler identifies the logic errors and suggests how to correct them.

program_1 (not program! 1program program )

Which of the following is a legal identifier?

output

The devices that the computer uses to display results are called ____ devices.

False

The escape sequence \r moves the insertion point to the beginning of the next line.

random access memory

Main memory is called ____.

True

Main memory is directly connected to the CPU.

Predefined or predefined or Standard or standard

____________________ functions are those that have already been written and are provided as part of the system.

Semantic or semantic

____________________ rules determine the meaning of instructions.


Kaugnay na mga set ng pag-aaral

Chapter 22 Care of Patients with Immune Function Excess: Hypersensitivity (Allergy) and Autoimmunity - Key points and questions

View Set

AP Gov. & Pol. Checks on the Judicial Branch

View Set

Livemocha - Turkish 101: Introduction

View Set

Science: Tides and the Lunar Cycle

View Set

Ch. 24- Nursing Care of the Child With an Alteration in Cellular Regulation/Hematologic or Neoplastic Disorder

View Set