CS22A MT

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

Computer programs are also known as: software firmware hardware silverware None of these

software

The statements written by the programmer are called: source code object code syntax runtime libraries None of these

source code

This statement lets the value of a variable or expression determine where the program will branch to. associative scope select switch None of these

switch

This is a set of rules that must be followed when constructing a program. key words operators punctuation portability syntax

syntax

If you place a semicolon after the statement if (x < y) the code will not compile the if statement will always evaluate to false the compiler will interpret the semicolon as a null statement All of the above None of these

the compiler will interpret the semicolon as a null statement

This operator performs a logical NOT operation. ! -- > No answer text provided. None of these

!

This operator takes an operand and reverses its truth or falsehood. arithmetic ! || relational None of these

!

This operator represents the logical AND. || ++ @ && None of these

&&

Character constants in C++ are always enclosed in ________. [brackets] {braces} "double quotation marks" (parentheses) 'single quotation marks'

'single quotation marks'

When this operator is used with string operands it concatenates them, or joins them together. % & * + None of these

+

What is the value stored at x, given the statements: int x; x = 3 / static_cast(4.5 + 6.4); .275229 .3 3.3 0 None of these

0

Which line in the following program will cause a compiler error? 1 #include 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 } 8 7 9 6

7 (Not Right)

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

8

Arithmetic operators that share the same precedence have right to left associativity. True False

False

If you do not follow a consistent programming style, your programs will generate compiler errors. True False

False

In C++, it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision. True False

False

In programming, the terms "line" and "statement" always mean the same thing. True False

False

Machine language is an example of a high-level language. True False

False

The C++ language requires that you give variables names that indicate what the variables are used for. True False

False

The default section is required in a switch statement. True False

False

The fixed manipulator causes a number to be displayed in scientific notation. True False

False

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

False

The preprocessor executes after the compiler. True False

False

What is the value of the following expression? true && false +1 true false -1

False

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

False

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

Fetch

What will the following code display? cout << "Four " << "score "; cout << "and " << "seven/n"; cout << "years" << "ago" << endl; Four score and seven/nyearsago Four score and seven yearsago Four score and seven yearsago Four score and seven years ago

Four score and seven/nyearsago

These are data items whose values do not change while the program is running. integers comments literals variables None of these

Literals

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

MondayTuesdayWednesday

The ________ operator always follows the cin object, and the ________ operator follows the cout object. conditional, binary binary, unary > >>, None of these

None of these

The computer's main memory is commonly known as: secondary storage the hard disk the floppy disk RAM None of these

RAM

In programming terms, a group of characters inside a set of quotation marks is called a: operation variable string literal statement None of these

String literal

What will the following segment of code output? score = 40; if (score > 95) cout << "Congratulations!\n"; cout << "That's a high score!\n"; cout << "This is a test question!" << endl; Congratulations! That's a high score! That's a high score! This is a test question! This is a test question! Congratulations! That's a high score! This is a test question! None of these

That's a high score! This is a test question!

In a C++ program, two slash marks ( // ) indicate: the end of a statement the beginning of a block of code the beginning of a comment the end of the program None of these

The beginning of a comment

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

X= (I don't know if it's right)

Which escape sequence causes the cursor to move to the beginning of the current line? \t \n \a \b \r

\r

This function tells the cin object to skip one or more characters in the keyboard buffer. cin.jump cin.ignore cin.hop cin.skip None of these

cin.ignore

Relational operators allow you to ________ numbers. multiply add compare average None of these

compare

To use the rand( ) function, you must #include this header file in your program. cstdlib iostream iomanip iorand None of these

cstdlib

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

double payCheck;

Pseudocode is a form of program statement that will always evaluate to "false." True False

false

________ reads a line of input, including leading and embedded spaces, and stores it in a string object. cin.get get cin.getline getline None of these

getline

Look at the following program and answer the question that follows it. 1 // This program displays my gross wages. 2 // I worked 40 hours and I make $20.00 per hour. 3 # include 4 using namespace std; 5 6 int main( ) 7 { 8 int hours; 9 double payRate, grossPay; 10 11 hours = 40; 12 payRate = 20.0; 13 grossPay = hours * payRate; 14 cout << "My gross pay is $" << grossPay << endl; 15 return 0; 16 } Which line(s) in this program cause output to be displayed on the screen? 8 and 9 15 14 13 and 14 13

14

In the C++ instruction, cookies = number % children; given the following declaration statement: int number = 38, children = 4, cookies; what is the value of cookies after the execution of the statement? 9 2 0 .5 None of these

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. 3, 4, 6, 7 are false. Only 5 is false. All are false. None of these

3 and 4 are false.

Which one of the following would be an illegal variable name? 3dGraph June1997 dayOfWeek itemsorderedforthemonth _employee_num

3dGraph

What will the value of x be after the following statements execute? int x; x = 18 / 4; 4.5 0 4 unknown

4

The total number of digits that appear before and after the decimal point is sometimes referred to as: floating points precision significant digits B and C None of these

B and C

________ are used to translate each source code instruction into the appropriate machine language instruction. Library routines Modules Preprocessor directives Compilers None of these

Compilers

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

True

C++ does not have a built in data type for storing strings of characters. True False

True

If the sub-expression on the left side of an && operator is false, the expression on the right side will not be checked. True False

True

If the sub-expression on the left side of the || operator is true, the expression on the right side will not be checked. True False

True

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

True

The only difference between the get function and the >> operator is that get reads the first character typed, even if it is a space, tab, or the [Enter] key. True False

True

When the fixed manipulator is used, the value specified by the setprecision manipulator will be the number of digits to appear after the decimal point. True False

True

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

True

You must have a ________ for every variable you intend to use in a program. comment definition purpose constant None of these

definition

Besides decimal, two other number systems you might encounter in C++ programs are: octal and fractal unary and quaternary hexadecimal and octal base 7 and base 9 None of these

hexadecimal and octal

When a program lets the user know that an invalid choice has been made, this is known as: compiler criticism output correction output validation input validation None of these

input validation

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; int x, y, z = 7, 16, 28 int x = 7, y = 16, z = 28; int x = 7 y = 16 z = 28; None of these will work.

int x = 7, y = 16, z = 28;

In a broad sense, the two primary categories of programming languages are: low-level and high-level mainframe and PC single-tasking and multi-tasking COBOL and BASIC None of these

low-level and high-level

When an if statement is placed within the conditionally-executed code of another if statement, this is known as: nesting validation complexity overloading None of these

nesting

The statement cin >> setw(10) >> str; will read up to this many characters into str. eleven eight nine ten None of these

nine

Which statement is equivalent to the following? number += 1; number = number + 1; number = 1; number + 1; None of these

number = number + 1

You can use these to override the rules of operator precedence in a mathematical expression. [brackets] (parentheses) the escape character \ {braces} None of these

parentheses

Even when there is no power to the computer, data can be held in: the algorithm the input device the output device secondary storage None of these

secondary storage

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 the operators that will be used on it the area of the code in which it will be used the number of times it will be used in the program None of these

the type of data it will be used to hold

Floating point constants are normally stored in memory as doubles. True False

true

Which statement is equivalent to the following? x = x * 2; x = x * x; x * 2; x *= 2; None of these

x *= 2;


Conjuntos de estudio relacionados

Chapter 23: Facility Design, Layout, and Organization

View Set

Lab 12-3 Application Software Installation and Configuration Methods

View Set

A&P 2 Chapter 19 test review questions

View Set

AP Gov Chapter #- Legislative Branch

View Set

Epidemiology Midterm Review- peer

View Set

Marketing exam 1 quiz questions ch. 1-3

View Set

Hey p.18-19, Hey p.22-23, Hey p.26-27, ימות השבוע, Hey p.28-29, Hey p.32-33

View Set

Chapter 13: Cardiac Rhythm Disturbances

View Set