Programming Final

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

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

+1

This operator takes an operand and reverses its truth or falsehood.

- !

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

- # include directive

Which of the following is a preprocessor directive?

- #include <iostream>

You can use these to override the rules of operator precedence in a mathematical expression.

- (parentheses)

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

- ++ and -

Assume that x is and int variable. What value is assigned to x after the following assignment is executed? X = -3 + 4 % 6 /

- -3

What will the following code display? Int x = 0; For (int count = 0; count <3; count++) X += count; Cout << x << endl;

- 0 - 1 - 2

What will the following loop display? Int x = 0; While (x <5) { Cout << x << endl; X++; }

- 0 - 1 - 2 - 3 - 4

What will the value of x be after the following statements execute? Int x = 0; Int y = 5; Int z = 4; X = y + z * 2;

- 13

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

- 15

In the C++ instruction, Cookies = number % children; Given the following statement: Int number = 38, children = 4, cookies; What is the value of the cookies after the execution of the statement?

- 2

What is the output of the following program? #include <iostream> Using namespace std; Int main() { Int x = 2; Cout << x << endl; doSomething(x); cout << x << endl; return 0; } void doSomething (int num) { Num = 0; Cout << num << endl; }

- 2 - 0 - 0

What is the output of the following program? #include <iostream> Using namespace std; Void doSomething (int&); Int main() { Int x = 2; Cout << x << endl; doSomething(x); cout << x << endl; return 0; } Void doSomething (int& num) { Num = 0; Cout << num << endl; }

- 2 - 2 - 2

How many times will the following loop display "Hello"? For (int I = 0; I < 20; i++) Cout << "Hello!" << endl;

- 20

Given the following code segment, what is output after "result = "? Int x = 1, y = 1, z = 1; Y = y + z; X = x + y; Cout << "result =" << (x < y ? y : x) << endl;

- 3

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

Assuming x is 5, y is 6, and z is 8, which of the following is false? 1. X == 5; 2. 7 <= (x+2); 3. Z <= 4; 4. (1 + x) != y; 5. Z >= 8; 6. X >= 0; 7. X <= (y * 2)

- 3 and 4 are false

What will the value of x be after the following statements execute? Int x; X = 16/4;

- 4

What is the output of the following program? #include <iostream> Using namespace std; void showDub(int); int main() { Int x = 2; showDub(x); cout << x << endl; return 0; } void showDub(int num) { Cout << (num * 2) << endl; }

- 4 - 2

Assuming you are using a system with 1-byte characters, how many bytes of memory will the following string literal occupy? "William"

- 8

This operator is used in C++ to represent equality.

- ==

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

- >>, <<

The while loop has 2 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

An Integrated Development Environment typically consists of:

- A text editor, debugger, and compiler

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

- Algorithm

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

- Argument, parameter

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

- Bool

Without this statement appearing in a switch construct, the program "falls through" all of the statements below the one with the matching expression.

- Break

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

- Cin object

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

- Closing brace

Relational operators aRE USED to ______________ numbers.

- Compare

________________ 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

Internally, the CPU consists of two parts:

- Control Unit - Arithmetic/Logic Unit

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

- Cout object

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

- Curly braces {}

Input values should always be chedked for:

- Division by zero - Reasonableness - Appropriate range

This is a variable, usually a Boolean or an integer, that signals when a condition exists.

- Flag

These are used to declare variables that can hold real numbers.

- Floating point data types

___________ reads a line of input, including leading and embedded spaces, and stores it in a string object.

- Getline

Three primary activities of a program are:

- Input - Processing - Output

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

- Integer and floating point

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 - myExtraLongVariableName - _employee_number - ___department o ANSWER IS ALL OF ABOVE

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

- Key Words

Assume that a program has the following variable definition: char letter; Which of the following statements correctly assigns the character Z to the variable?

- Letter = 'Z'

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

- Logic errors

Assume that a program has the following string object definition: String name; Which of the following statements correctly assigns a string literal to the string object?

- Name = "Jane";

When an if statement is placed withing the conditionally-executed code of another if statement, this is known as:

- Nesting

If you use C++ key word as an identifier, your program will:

- Not compile

Which statement is equivalent to the following? Number += 1;

- Number = Number + 1;

Which of the following is not one of the five major components of a computer system?

- Preprocessor

A ________________ is a set of instructions that the computer follows to solve a problem.

- Program

The computer's main memory is commonly known as:

- RAM

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

- Reach

The ____________ of a variable is limited to the block in which it is declared.

- Scope

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

- Semicolon

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

- Setw

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

- Single, double

The statements written by the programmer are called:

- Source Code

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

- The beginning of a comment

What does the term hardware refer to?

- The physical components that a computer is made of

What is assigned to the variable a given the statement below with the following assumptions: X = 10 Y = 7 Z, a, and b are all int variables A = x>= y;

- The string "x >= y"

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

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

- Variables

Which statement is equivalent to the following? X = x * 2;

- X *= 2;

Which data type typically requires only one byte of storage?

- char

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

- iostream header file

This function in C++ allows you to identify how many bytes of storage on your computer system an integer data value requires.

- sizeof

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

- string literal

This operator is known as the logical OR operator

- ||

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

LOCAL

A loop that is inside another loop is called:

NESTED LOOP

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

The while loop is this type of loop.

PRE TEST

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

PREFIX

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

REFERENCE

This statement causes a function to end.

RETURN

The value in this type of local variable persists between function calls.

STATIC

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

STUB

A static variable that is defined witihin a function is initialized only once, the first time the function is called.

T

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

T

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

T

ne reason for using functions is to break programs into manageable units, or modules

T

A CPU really only understands instructions that are written in machine language.

True

A preprocessor directive does not require a semicolon at the end.

True

In C++, key words are written in all lowercase letters.

True

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

VARIABL

Which of the following expressions will detwermine whether x is less than or equal to y?

X <= Y

The preprocessor executes after the compiler.

False

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.

INITIALIZATOIN

Look at the following function prototype. Int myFunction(double); What is the data type of the function's return value?

INT

To read data from a file, you define an object of this data type.

ifstream

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;

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

ofstream

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; }

1

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

What is the value of donuts after the following code executes? Int donuts = 10; If (donuts != 10) Donuts = 0; Else Donuts +=2;

12

What will the following code display? Int number = 6; Int x = 0; X = number--; Cout << x << endl;

6

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 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 function is executed when it is:

CALLED

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

COUNTER

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

DEFINITION

The condition that is tested by a while loop myst be enclosed in parentheses and terminated with a semicolon.

F

The default section is required in a switch statement.

F

The following code correctly determines whether x contains a value in the range of 0 through 100. If ( x>= 0 && <= 100)

F

When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive,

F

You may nest while and do-while loops, by you may not nest for loops.

F

You must furnish an argument with a function call.

F

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

FSTREAM

A variable called "average" should be declared as an integer data type because it will probably hold data that contains decimal places.

False


Set pelajaran terkait

Interpersonal Relationship prepU

View Set

Software Engineering Final Study Guide(Diego Fernandez)

View Set

Exam 5: Child and Adolescent Mental Health

View Set

Caring for Central Vascular Access Devices (CVAD) - EXAM

View Set

Economics- Unit 3: Microeconomics

View Set