Quiz 2-10 CIST 2361 practice

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

Given that x = 2, y = 1, z = 0, what will the following cout statement display? "answer = " << (x || !y && z) << endl; Selected Answer: Correct answer = 1 Answers: answer = 0 Correct answer = 1 answer = 2 None of theseGiven that x = 2, y = 1, z = 0, what will the following cout statement display? Selected Answer: answer = 1Answers:answer = 0 answer = 1answer = 2None of these

Given that x = 2, y = 1, z = 0, what will the following cout statement display? "answer = " << (x || !y && z) << endl; Answers: answer = 0 answer = 1 answer = 2 None of these

Given the if/else statement: if (a<5) b=12; else d=30; Which of the following performs the same operation? ed Answer: Correct a < 5 ? b = 12 : d = 30; Answers: Correct a < 5 ? b = 12 : d = 30; b < 5 ? b = 12 : d = 30; a >= 5 ? d = 30 : b = 12; d = 30 ? b = 12 : a = 5;

Given the if/else statement: if (a<5) b=12; else d=30; Which of the following performs the same operation? Answers: a < 5 ? b = 12 : d = 30; b < 5 ? b = 12 : d = 30; a >= 5 ? d = 30 : b = 12; d = 30 ? b = 12 : a = 5; None of these

How many elements does the following array have? int values[1000]; Selected Answer: Correct 1000 Answers: Correct 1000 999 1001 cannot tell from the code

How many elements does the following array have? int values[1000]; Answers: 1000 999 1001 cannot tell from the code

If you are using the bubble sort algorithm to sort an array in descending order, the smaller values move toward the end. Selected Answer: Correct True Answers: Correct True False

If you are using the bubble sort algorithm to sort an array in descending order, the smaller values move toward the end. Answers: True False

To pass an array as an argument to a function, pass the ________ of the array. Selected Answer: Incorrect size, expressed as an integer Answers: contents size, expressed as an integer Correct name value of the first element None of these

To pass an array as an argument to a function, pass the ________ of the array. Answers: contents size, expressed as an integer name value of the first element None of these

To use the rand()function, you must include the ________ header file? Selected Answer: Correct cstdlib Answers: cstring iostream cstdlib iomanip cmath

To use the rand()function, you must include the ________ header file? Answers: cstring iostream cstdlib iomanip cmath

What is output of the following statement? cout << 4 * (15 / (1 + 3)) << endl; Selected Answer: Incorrect 15 Answers: 15 Correct 12 63 72 None of these

What is output of the following statement? cout << 4 * (15 / (1 + 3)) << endl; Answers: 15 12 63 72 None of these

What is the output of the following code segment if the user enters 23? int number; cout << "Enter a number: "; cin >> number; if (number > 0) cout << "Hi, there!" << endl; else cout << "Good-bye." << endl; Answers: Hi, there! Good-bye. Correct Hi, there! Good-bye. "Hi, there!" nothing will output

What is the output of the following code segment if the user enters 23? int number; cout << "Enter a number: "; cin >> number; if (number > 0) cout << "Hi, there!" << endl; else cout << "Good-bye." << endl; Answers: Hi, there! Good-bye. Hi, there! Good-bye. "Hi, there!" nothing will output

A ________ search is more efficient than a ________ search. Selected Answer: Correct binary, linear Answers: character, string integer, double Correct binary, linear linear, binary None of these

A ________ search is more efficient than a ________ search. Answers: character, string integer, double binary, linear linear, binary None of these

A computer stores a program while it is running Selected Answer: Correct in main memory Answers: Correct in main memory on a hard disk on the computer monitor in the CPU None of these

A computer stores a program while it is running Answers: in main memory on a hard disk on the computer monitor in the CPU None of these

A computer touch monitor is a type of Selected Answer: Correct input/output device Answers: Correct Input/output device output device storage device software None of these

A computer touch monitor is a type of Answers: input/output device output device storage device software None of these

A debugging process where you, the programmer, pretend you are a computer and step through each statement while recording the value of each variable at each step is known as Selected Answer: Correct hand tracing Answers: error checking hand writing Correct hand tracing error handling None of these

A debugging process where you, the programmer, pretend you are a computer and step through each statement while recording the value of each variable at each step is known as Answers: error checking hand writing hand tracing error handling None of these

A linear search can only be implemented with integer values. Selected Answer: Correct False Answers: True Correct False

A linear search can only be implemented with integer values. Answers: True False

A model often used when creating a program that begins with the overall task and refines it into smaller subtasks is a(n) Selected Answer: Correct hierarchy chart Answers: flowchart UML diagram blueprint Correct hierarchy chart None of these

A model often used when creating a program that begins with the overall task and refines it into smaller subtasks is a(n) Answers: flowchart UML diagram blueprint hierarchy chart None of these

A named constant is like a variable, but it its content cannot be changed while the program is running. Selected Answer: CorrectTrue Answers: CorrectTrue False

A named constant is like a variable, but it its content cannot be changed while the program is running. Answers: True False

An array's size declarator must be a ________ with a value greater than ________. Selected Answer: Correct constant integer expression, zero Answers: number, one number, zero Correct constant integer expression, zero variable, -1 None of these

An array's size declarator must be a ________ with a value greater than ________. Answers: number, one number, zero constant integer expression, zero variable, -1 None of these

Arithmetic operators that share the same precedence have right to left associativity. Selected Answer: CorrectFalse Answers: True False

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

Assuming that a program has the following string object definition, which statement correctly assigns the string literal "Jane" to the string object? string name; Selected Answer: Correct name = "Jane"; Answers: Correct name = "Jane"; name = Jane; string name = {Jane}; name = 'Jane';

Assuming that a program has the following string object definition, which statement correctly assigns the string literal "Jane" to the string object? string name; Answers: name = "Jane"; name = Jane; string name = {Jane}; name = 'Jane';

At the heart of a computer is its central processing unit. The CPU's job is: Selected Answer: Correct All of these Answers: to fetch instructions to carry out the operations commanded by the instructions to produce some outcome or resultant information Correct All of these None of these

At the heart of a computer is its central processing unit. The CPU's job is: Answers: to fetch instructions to carry out the operations commanded by the instructions to produce some outcome or resultant information All of these None of these

Before you can perform a bubble sort, the data must be stored in descending order. Selected Answer: False Answers: True Correct False

Before you can perform a bubble sort, the data must be stored in descending order. Answers: True False

In the process of translating a source file into an executable file, which of the following is the correct sequence? Selected Answer: Correct Source code, preprocessor, modified source code, compiler, object code, linker, executable code. Answers: Source code, preprocessor, modified source code, linker, object code, compiler, executable code Correct Source code, preprocessor, modified source code, compiler, object code, linker, executable code. Preprocessor, source code, compiler, executable code, linker, modified source code, object code Source code, compiler, modified source code, preprocessor, object code, linker, executable code. Source code, linker, object code, compiler, modified source code, preprocessor, executable code.

In the process of translating a source file into an executable file, which of the following is the correct sequence? . Answers: Source code, preprocessor, modified source code, linker, object code, compiler, executable code Source code, preprocessor, modified source code, compiler, object code, linker, executable code. Preprocessor, source code, compiler, executable code, linker, modified source code, object code Source code, compiler, modified source code, preprocessor, object code, linker, executable code. Source code, linker, object code, compiler, modified source code, preprocessor, executable code.

Mistakes that cause a running program to produce incorrect results are called: Selected Answer: Correct logic errors Answers: syntax errors Correct logic errors compiler errors linker errors None of these

Mistakes that cause a running program to produce incorrect results are called: Answers: syntax errors logic errors compiler errors linker errors None of these

Programs are normally stored in ________ and loaded into main memory as needed. Selected Answer: Incorrect None of these Answers: the input device the output device Correct secondary storage the CPU None of these

Programs are normally stored in ________ and loaded into main memory as needed. Answers: the input device the output device secondary storage the CPU None of these

The ________ is an equality (or comparison) operator. Selected Answer: Correct == Answers: Correct == >= != = None of these

The ________ is an equality (or comparison) operator. Answers: == >= != = None of these

The individual values contained in an array are known as Selected Answer: Correct elements Answers: parts items constants Correct elements None of these

The individual values contained in an array are known as Answers: parts items constants elements None of these

The programmer usually enters source code into a computer with Selected Answer: Correct a text editor Answers: a hierarchy chart Correct a text editor a compiler pseudocode None of these

The programmer usually enters source code into a computer with Answers: a hierarchy chart a text editor a compiler pseudocode None of these

Which of the following statements will pause the screen until the [Enter] key is pressed? Selected Answer: Correct cin.get(); Answers: cin.getline(); Correct cin.get(); cin.ignore(); cin; cin.input();

Which of the following statements will pause the screen until the [Enter] key is pressed? Answers: cin.getline(); cin.get(); cin.ignore(); cin; cin.input();

Which step uncovers any syntax errors in your program? Selected Answer: Correct compiling Answers: editing Correct compiling linking executing None of these

Which step uncovers any syntax errors in your program? Answers: editing compiling linking executing None of these

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"; Selected Answer: Correct 99 Answers: 100 10 Correct 99 0 all of these

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"; Answers: 100 10 99 0 all of these

Words that have a special meaning and may be used only for their intended purpose are known as Answer: key words Answers: operators programmer defined words key words syntax None of these

Words that have a special meaning and may be used only for their intended purpose are known as Answers: operators programmer defined words key words syntax None of these

A set of well-defined steps for performing a task or solving a problem is known as a(n): Selected Answer: Correct algorithm Answers: hierarchy chart Correct algorithm instruction set statement None of these

A set of well-defined steps for performing a task or solving a problem is known as a(n): : Answers: hierarchy chart algorithm instruction set statement None of these

A statement that starts with a hashtag (or pound) symbol ( #) is called a Selected Answer: Correct preprocessor directive Answers: comment function Correct preprocessor directive header file None of these

A statement that starts with a hashtag (or pound) symbol ( #) is called a Answers: comment function preprocessor directive header file None of these

A two-dimensional array can be viewed as Selected Answer: Correct rows and columns Answers: Correct rows and columns arguments and parameters increments and decrements All of these None of these

A two-dimensional array can be viewed as Answers: rows and columns arguments and parameters increments and decrements All of these None of these

A two-dimensional array can have elements of ________ data type(s). Selected Answer: Correct one Answers: Correct one two four any number of None of these

A two-dimensional array can have elements of ________ data type(s). Answers: one two four any number of None of these

A variable definition defines the name of a variable that will be used in a program, as well as: Selected Answer: Correct the type of data it will be used to hold Answers: Correct the type of data it will be used to hold the operators that will be used on it the number of times it will be used in the program the value it will hold None of these

A variable definition defines the name of a variable that will be used in a program, as well as: Answers: the type of data it will be used to hold the operators that will be used on it the number of times it will be used in the program the value it will hold None of these

A variable's ________ is the part of the program that has access to the variable. Selected Answer: Correct scope Answers: data type value Correct scope assignment None of these

A variable's ________ is the part of the program that has access to the variable. Answers: data type value scope assignment None of these

A volatile type of memory that is used for temporary storage is Selected Answer: Correct RAM Answers: an address the ALU Correct RAM a disk drive None of these

A volatile type of memory that is used for temporary storage is Answers: an address the ALU RAM a disk drive None of these

A(n) ________ can be used to specify the starting values of an array. Selected Answer: Correct initialization list Answers: Correct initialization list array name subscript element None of these

A(n) ________ can be used to specify the starting values of an array. Answers: initialization list array name subscript element None of these

A(n) ________ is a set of instructions that the computer follows to solve a problem. Selected Answer: Correct program Answers: compiler linker Correct program operator None of these

A(n) ________ is a set of instructions that the computer follows to solve a problem. Answers: compiler linker program operator None of these

A(n) ________ represents a storage location in the computer's memory. Selected Answer: Correct variable Answers: literal Correct variable comment integer None of these

A(n) ________ represents a storage location in the computer's memory. Answers: literal variable comment integer None of these

A(n) ________ search uses a loop to sequentially step through an array. Selected Answer: Correct linear Answers: binary unary Correct linear relative None of these

A(n) ________ search uses a loop to sequentially step through an array. Answers: binary unary linear relative None of these

An Integrated Development Environment (IDE) typically consists of Selected Answer: Correct All of these Answers: a text editor a compiler a debugger Correct All of these None of these

An Integrated Development Environment (IDE) typically consists of Answers: a text editor a compiler a debugger All of these None of these

An array can easily be stepped through by using a Selected Answer: Correct a for loop Answers: Correct a for loop a reference variable an array prototype a null value None of these

An array can easily be stepped through by using a Answers: a for loop a reference variable an array prototype a null value None of these

An element of a two-dimensional array is referred to by Selected Answer: Correct the row subscript of the element followed by the column subscript of the element Answers: the array name followed by the column number of the element Correct the row subscript of the element followed by the column subscript of the element a comma followed by a semicolon the row subscript of the element followed by the array name None of these

An element of a two-dimensional array is referred to by Answers: the array name followed by the column number of the element the row subscript of the element followed by the column subscript of the element a comma followed by a semicolon the row subscript of the element followed by the array name None of these

Before you can perform a selection sort, the data must be stored in ascending order. Selected Answer: Correct False Answers: True Correct False

Before you can perform a selection sort, the data must be stored in ascending order. Answers: True False

Besides the decimal number system that is most common (base 10), two other number systems that can be used in C++ programs are Selected Answer: Correct octal and hexadecimal Answers: octal and fractal Correct octal and hexadecimal base 2 and base 4 base 2 and binary None of these

Besides the decimal number system that is most common (base 10), two other number systems that can be used in C++ programs are Answers: octal and fractal octal and hexadecimal base 2 and base 4 base 2 and binary None of these

Characters or symbols that perform operations on one or more operands are: Selected Answer: Correct operators Answers: separators op codes Correct operators key words None of these

Characters or symbols that perform operations on one or more operands are: Answers: separators op codes operators key words None of these

If you intend to place a block of statements within an if statement, you must place ________ around the block. Selected Answer: Correct curly braces { } Answers: parentheses( ) square brackets [ ] Correct curly braces { } None of these

If you intend to place a block of statements within an if statement, you must place ________ around the block. Answers: parentheses( ) square brackets [ ] curly braces { } None of these

If you want a user to enter exactly 20 values, which loop would be the best to use? Selected Answer: Correct for Answers: while Correct for switch do-while None of these

If you want a user to enter exactly 20 values, which loop would be the best to use? Answers: while for switch do-while None of these

If you want to know the length of the string that is stored in a string object, you can call the object's size member function. Selected Answer: Correct False Answers: True Correct False

If you want to know the length of the string that is stored in a string object, you can call the object's size member function. Answers: True False

In a cout statement, which of the following will advance the output position to the beginning of the next line? Selected Answer: Correct endl or \n Answers: \t or \b end1 or /n \n or \t Correct endl or \n \\ or \'

In a cout statement, which of the following will advance the output position to the beginning of the next line? Answers: \t or \b end1 or /n \n or \t endl or \n \\ or \'

The CPU's control unit retrieves the next instruction in a sequence of program instructions from main memory in the ________ stage. Selected Answer: Correct fetch Answers: portability Correct fetch decode execute

The CPU's control unit retrieves the next instruction in a sequence of program instructions from main memory in the ________ stage. Answers: portability fetch decode execute

The ________ causes a program to wait until information is typed at the keyboard and the [Enter] key is pressed. Selected Answer: Correct cin object Answers: output stream Correct cin object cout object preprocessor None of these

The ________ causes a program to wait until information is typed at the keyboard and the [Enter] key is pressed. Answers: output stream cin object cout object preprocessor None of these

The ________ causes the content of another file to be inserted into a program. Selected Answer: Correct #include directive Answers: cout object double slash (//) Correct #include directive semicolon (;) None of these

The ________ causes the content of another file to be inserted into a program. Answers: cout object double slash (//) #include directive semicolon (;) None of these

The ________ is adequate for searching through small arrays. Selected Answer: Correct the linear search Answers: binary search Correct the linear search unary search bubble sort None of these

The ________ is adequate for searching through small arrays. Answers: binary search the linear search unary search bubble sort None of these

The ________ loop is a good choice when you do not want the loop to iterate if the condition is FALSE in the beginning. Selected Answer: Correct while Answers: switch infinite Correct while do-while post-test

The ________ loop is a good choice when you do not want the loop to iterate if the condition is FALSE in the beginning. Answers: switch infinite while do-while post-test

The ________ loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop. Selected Answer: Correct for Answers: switch pre-test Correct for do-while while

The ________ loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop. Answers: switch pre-test for do-while while

The ________ loop is ideal in situations where you want the loop to iterate at least once. Selected Answer: Correct do-while Answers: for switch pre-test while Correct do-while

The ________ loop is ideal in situations where you want the loop to iterate at least once. Answers: for switch pre-test while do-while

The ________ sort usually performs fewer exchanges than the ________ sort. Selected Answer: Correct selection, bubble Answers: bubble, selection binary, linear Correct selection, bubble ANSI, ASCII None of these

The ________ sort usually performs fewer exchanges than the ________ sort. Answers: bubble, selection binary, linear selection, bubble ANSI, ASCII None of these

The advantage of a linear search is its Selected Answer: Correct simplicity Answers: complexity efficiency Correct simplicity speed None of these

The advantage of a linear search is its Answers: complexity efficiency simplicity speed None of these

The do-while loop is considered Selected Answer: Correct a post-test loop Answers: a pre-test loop Correct a post-test loop an infinite loop a counter-controlled loop None of these

The do-while loop is considered Answers: a pre-test loop a post-test loop an infinite loop a counter-controlled loop None of these

The first step in writing a program is to Selected Answer: Correct clearly define what the program is to do Answers: type the code visualize the program running on a computer visualize logical errors Correct clearly define what the program is to do None of these

The first step in writing a program is to type the code visualize the program running on a computer visualize logical errors clearly define what the program is to do None of these

Correct The fixed manipulator causes a number to be displayed in scientific notation. Selected Answer: Correct False Answers: True Correct False

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

The following is the pseudocode for which type of algorithm? Set first to 0 Set last to the last subscript in the array Set found to false Set position to -1 While found is not true and first is less than or equal to last Set middle to the subscript halfway between array[first] and array[last] If array[middle] equals the desired value Set found to true Set position to middle Else If array[middle] is greater than the desired value Set last to middle - 1 Else Set first to middle + 1 End If End While Return position Selected Answer: binary search Answers: linear sort linear search Correct binary search selection sort None of these

The following is the pseudocode for which type of algorithm? Set first to 0 Set last to the last subscript in the array Set found to false Set position to -1 While found is not true and first is less than or equal to last Set middle to the subscript halfway between array[first] and array[last] If array[middle] equals the desired value Set found to true Set position to middle Else If array[middle] is greater than the desired value Set last to middle - 1 Else Set first to middle + 1 End If End While Return position Answers: a. linear sort b. linear search c. binary search d. selection sort e. None of these

The programming process consists of several steps, which include: Selected Answer: Correct design, creation, testing, debugging Answers: key words, operator definitions, punctuation Correct design, creation, testing, debugging input, processing, output syntax, logic, error handling None of these

The programming process consists of several steps, which include: key words, operator definitions, punctuation design, creation, testing, debugging input, processing, output syntax, logic, error handling None of these

The purpose of a memory address is: Selected Answer: Correct to identify the location of a byte in memory Answers: Correct to identify the location of a byte in memory to prevent multitasking to obtain an algorithm to improve the speed of processing

The purpose of a memory address is: Answers: to identify the location of a byte in memory to prevent multitasking to obtain an algorithm to improve the speed of processing

The two methods used by C++ to write computer programs are: Selected Answer: Correct procedural programming and object-oriented programming Answers: top-down programming and procedural programming Correct procedural programming and object-oriented programming pseudocoding and object-oriented programming flowcharting and procedural programming None of these

The two methods used by C++ to write computer programs are: Answers: top-down programming and procedural programming procedural programming and object-oriented programming pseudocoding and object-oriented programming flowcharting and procedural programming None of these

The two parts of the CPU are Selected Answer: Correct the Control Unit and the Arithmetic and Logic Unit Answers: the output device and the input device the software and the hardware Correct the Control Unit and the Arithmetic and Logic Unit the single-task device and the multi-task device None of these

The two parts of the CPU are Answers: the output device and the input device the software and the hardware the Control Unit and the Arithmetic and Logic Unit the single-task device and the multi-task device None of these

This following statement shows an example of ________. int grades][ ] = {100, 90, 99, 80}; Selected Answer: Correct implicit array sizing Answers: default arguments an illegal array declaration an illegal array initialization Correct implicit array sizing None of these

This following statement shows an example of ________. int grades][ ] = {100, 90, 99, 80}; Answers: default arguments an illegal array declaration an illegal array initialization implicit array sizing None of these

This is used in a program to mark the beginning or ending of a statement, or separate items in a list: Selected Answer: Correct punctuation Answers: separators Correct punctuation operators key words None of these

This is used in a program to mark the beginning or ending of a statement, or separate items in a list: Answers: separators punctuation operators key words None of these

This manipulator causes the field to be left justified with padding spaces printed to the right: Selected Answer: Correct left Answers: left_justify right Correct left left_pad None of these

This manipulator causes the field to be left justified with padding spaces printed to the right: Answers: left_justify right left left_pad None of these

This means to increase a value: Selected Answer: Correct increment Answers: decrement Correct increment modulus parse None of these

This means to increase a value: Answers: decrement increment modulus parse None of these

This operator represents the logical AND: Selected Answer: Correct && Answers: ++ || Correct && @ None of these

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

This statement uses the value of a variable or expression to determine where the program will branch to. Selected Answer: Correct switch Answers: Correct switch select association scope None of these

This statement uses the value of a variable or expression to determine where the program will branch to. Answers: switch select association scope None of these

To access an array element, use the array name and the element's ________. Selected Answer: Correct subscript Answers: data type Correct subscript value name None of these

To access an array element, use the array name and the element's ________. Answers: data type subscript value name None of these

What is the output of the following code segment if the user enters 90 for the score? cout << "Enter your test score: "; cin >> test_score; if (test_score < 60) cout << "You failed the test." << endl; if (test_score > 60) cout << "You passed the test." else cout << "You need to study harder next time." << endl; Selected Answer: Correct You passed the test. Answers: You failed the test. You need to study harder next time. You failed the test. You need to study harder next time. You passed the test. You need to study harder next time. Correct You passed the test.

What is the output of the following code segment if the user enters 90 for the score? cout << "Enter your test score: "; cin >> test_score; if (test_score < 60) cout << "You failed the test." << endl; if (test_score > 60) cout << "You passed the test." else cout << "You need to study harder next time." << endl; Answers: You failed the test. You need to study harder next time. You failed the test. You need to study harder next time. You passed the test. You need to study harder next time. You passed the test.

What is the output of the following code segment? int x = 5; if (x = 2)cout << "This is true!" << end1; else cout << "This is false!" << end1; cout << "That's all, folks!" << endl; nswer: Correct This is true! That's all folks Answers: This is false! This is true! This is false! That's all, folks! Correct This is true! That's all folks This is false! That's all, folks This is true!

What is the output of the following code segment? int x = 5; if (x = 2)cout << "This is true!" << end1; else cout << "This is false!" << end1; cout << "That's all, folks!" << endl; nswer: This is true! That's all folks Answers: This is false! This is true! This is false! That's all, folks! \This is true! That's all folks This is false! That's all, folks This is true!

What is the value of cookies after the following statements execute? int number = 38, children = 4, cookies; cookies = number % children; Selected Answer: Correct 2 Answers: 9 4 Correct 2 9.5 .5

What is the value of cookies after the following statements execute? int number = 38, children = 4, cookies; cookies = number % children; Selected Answer: Answers: 9 4 2 9.5 .5

What is the value of cube after the following code executes? double cube, side; side = 5.0; cube = pow(side, 3.0); Selected Answer: Correct 125.0 Answers: 25.0 15.0 Correct 125.0 8.0 unknown

What is the value of cube after the following code executes? double cube, side; side = 5.0; cube = pow(side, 3.0); Answers: 25.0 15.0 125.0 8.0 unknown

What is the value of donuts after the following code executes? int donuts = 10; if (donuts = 1) donuts = 0; else donuts += 2; Selected Answer: Correct 0 Answers: 12 10 Correct 0 1 None of these

What is the value of donuts after the following code executes? int donuts = 10; if (donuts = 1) donuts = 0; else donuts += 2; Answers: 12 10 0 1 None of these

What is the value of number after the following statements execute? int number; number = 18 % 4 + 2; Selected Answer: Correct 4 Answers: 3 Correct 4 6.5 0 unknown

What is the value of number after the following statements execute? int number; number = 18 % 4 + 2; Answers: 3 4 6.5 0 unknown

What is the value of the following expression? true && true Selected Answer: Correct true Answers: Correct true false -1 +1 None of these

What is the value of the following expression? true && true Answers: true false -1 +1 None of these

What is the value of the following expression? true || false Selected Answer: Correct true Answers: Correct true false -1 +1 None of these

What is the value of the following expression? true || false Answers: true false -1 +1 None of these

What is the value stored at x, given the statements: int x; x = 3 / static_cast<int>(4.5 + 6.4); Selected Answer: correct 0 Answers: 0.3 Correct 0 0.275229 3.3 None of these

What is the value stored at x, given the statements: int x; x = 3 / static_cast<int>(4.5 + 6.4); Answers: 0.3 0 0.275229 3.3 None of these

What will be displayed after the following statements execute? int num1 = 5; int num2 = 3; cout << "The result is " << (num1 * num2 + 10) << endl; Selected Answer: Correct The result is 25 Answers: The result is 5 * 3 + 10 The result is (num1 * num2 + 10) Correct The result is 25 The result is 65 None of these

What will be displayed after the following statements execute? int num1 = 5; int num2 = 3; cout << "The result is " << (num1 * num2 + 10) << endl; Answers: The result is 5 * 3 + 10 The result is (num1 * num2 + 10) The result is 25 The result is 65 None of these

What will be the output of the following code segment after the user enters 0 at the keyboard? int x = -1; cout << "Enter a 0 or a 1 from the keyboard: "; cin >> x; if (c) cout << "true" << endl; else cout << "false" << endl; Selected Answer: Incorrect false Answers: Correct nothing will be displayed, program has an error. false x true 0

What will be the output of the following code segment after the user enters 0 at the keyboard? int x = -1; cout << "Enter a 0 or a 1 from the keyboard: "; cin >> x; if (c) cout << "true" << endl; else cout << "false" << endl; Answers: nothing will be displayed, program has an error. false x true 0

What will the following code display? int number = 23; cout << "The number is " << "number" << endl; Selected Answer: Correct The number is number Answers: The number is The number is 23 Correct The number is number The number is null The number is23 Thursday, February 27, 2020 10:45:26 AM EST

What will the following code display? int number = 23; cout << "The number is " << "number" << endl; Answers: The number is The number is 23 The number is number The number is null The number is23 Thursday, February 27, 2020 10:45:26 AM EST

What will the following code display? int number = 6; ++number; cout << number << endl; Selected Answer: Correct 7 Answers: 6 5 Correct 7 0

What will the following code display? int number = 6; ++number; cout << number << endl; Answers: 6 5 7 0

What will the following code display? int number = 6; int x = 0; x = --number; cout << x << endl; Selected Answer: Correct 5 Answers: 6 Correct 5 7 0

What will the following code display? int number = 6; int x = 0; x = --number; cout << x << endl; Answers: 6 5 7 0

What will the following code display? int number = 6; int x = 0; x = number--; cout << x << endl; Selected Answer: Correct 6 Answers: Correct 6 5 7 0

What will the following code display? int number = 6; int x = 0; x = number--; cout << x << endl; Answers: 6 5 7 0

What will the following code display? int x = 23, y = 34, z = 45; cout << x << y << z << endl; Selected Answer: Correct 233445 Answers: xyz 23 34 45 23 34 45 Correct 233445

What will the following code display? int x = 23, y = 34, z = 45; cout << x << y << z << endl; Answers: xyz 23 34 45 23 34 45 233445

What will the following code display? int numbers[] = {99, 87, 66, 55, 101}; cout << numbers[3] << endl; Selected Answer: Correct 55 Answers: 87 101 Correct 55 66

What will the following code display? int numbers[] = {99, 87, 66, 55, 101}; cout << numbers[3] << endl; Answers: 87 101 55 66

What will the following code display? int numbers[] = {99, 87, 66, 55, 101}; for (int i = 1; i < 4; i++) cout << numbers[i] << " "; Selected Answer: Correct 87 66 55 Answers: 99 87 66 55 101 87 66 55 101 Correct 87 66 55 Nothing. This code has an error.

What will the following code display? int numbers[] = {99, 87, 66, 55, 101}; for (int i = 1; i < 4; i++) cout << numbers[i] << " "; Answers: 99 87 66 55 101 87 66 55 101 87 66 55 Nothing. This code has an error.

What will the following loop display? int x = 0; while (x < 5) { cout << x << endl; x++; } Selected Answer: Correct 0 1 2 3 4 Answers: 0 1 2 3 4 5 Correct 0 1 2 3 4 0 1 2 3 4 This is an infinite loop

What will the following loop display? int x = 0; while (x < 5) { cout << x << endl; x++; } Answers: 0 1 2 3 4 5 0 1 2 3 4 0 1 2 3 4 This is an infinite loop

When a programmer saves to a file the statements he or she writes to create a program, these statements are Selected Answer: Correct source code Answers: high level Correct source code a preprocessor file object code None of these

When a programmer saves to a file the statements he or she writes to create a program, these statements are Answers: high level source code a preprocessor file object code None of these

When a user types values at the keyboard, those values are first stored Selected Answer: Correct in the keyboard buffer Answers: as ASCII characters in the header file iostream Correct in the keyboard buffer as integers None of these

When a user types values at the keyboard, those values are first stored Answers: as ASCII characters in the header file iostream in the keyboard buffer as integers None of these

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; Answer: line 7 Answers: line 6 line 7 line 8 line 9 there will be no compiler error 10 }

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 } Answers: line 6 line 7 line 8 line 9 there will be no compiler error

Which of the following best describes an operator? Selected Answer: Correct An operator allows you to perform operations on one or more pieces of data. Answers: An operator marks the beginning or ending of a statement, or is used to separate items in a list. Correct An operator allows you to perform operations on one or more pieces of data. An operator is a rule that must be followed when constructing a program. An operator is a symbolic name that refers to a variable. An operator is a word that has a special meaning.

Which of the following best describes an operator? Answers: An operator marks the beginning or ending of a statement, or is used to separate items in a list. An operator allows you to perform operations on one or more pieces of data. An operator is a rule that must be followed when constructing a program. An operator is a symbolic name that refers to a variable. An operator is a word that has a special meaning.

Which of the following defines a double-precision floating-point variable named payCheck? Selected Answer: Correct double payCheck; Answers: Correct double payCheck; float payCheck; payCheck double; Double payCheck;

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

Which of the following expressions will determine whether x is less than or equal to y? Selected Answer: Correct x <= y Answers: x >= y x > y x =< y Correct x <= y x == y and x < y

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

Which of the following functions tells the cin object to skip one or more characters in the keyboard buffer? Selected Answer: Correct cin.ignore Answers: Correct cin.ignore cin.jump cin.hop cin.skip None of these

Which of the following functions tells the cin object to skip one or more characters in the keyboard buffer? Answers: cin.ignore cin.jump cin.hop cin.skip None of these

Which of the following functions will return the value of x, rounded to the nearest whole number? Selected Answer: Correct round(x) Answers: fmod(x) sqrt(x) abs(x) Correct round(x) whole(x)

Which of the following functions will return the value of x, rounded to the nearest whole number? Answers: fmod(x) sqrt(x) abs(x) round(x) whole(x)

Which of the following is a valid C++ array definition? Selected Answer: Correct int scores[25]; Answers: int array[0]; float $payments[10.23]; int numbers[5.6]; Correct int scores[25]; None of these

Which of the following is a valid C++ array definition? Answers: int array[0]; float $payments[10.23]; int numbers[5.6]; int scores[25]; None of these

Which of the following is a valid C++ array definition? Selected Answer: Correct int sizes[10]; Answers: int nums[0]; float $payments[10]; void numbers[5]; Correct int sizes[10]; None of these

Which of the following is a valid C++ array definition? Answers: int nums[0]; float $payments[10]; void numbers[5]; int sizes[10]; None of these

Which of the following statements correctly defines a named constant named TAX_RATE that holds the value 0.075? Selected Answer: Correct const double TAX_RATE = 0.075; Answers: double TAX_RATE; const TAX_RATE = 0.075; double TAX_RATE = 0.075; const TAX_RATE = 0.075; Correct const double TAX_RATE = 0.075; const TAX_RATE; double TAX_RATE = 0.075;

Which of the following statements correctly defines a named constant named TAX_RATE that holds the value 0.075? Answers: double TAX_RATE; const TAX_RATE = 0.075; double TAX_RATE = 0.075; const TAX_RATE = 0.075; const double TAX_RATE = 0.075; const TAX_RATE; double TAX_RATE = 0.075;


Set pelajaran terkait

Accreditation and Regulatory Compliance

View Set

Eleven Fifty Cybersecurity Network+ Chapter 10

View Set

2017 National Electrical Code Article 240, Overcurrent Protection

View Set

RN Comprehensive Online Practice 2019 B with NGN

View Set

US History GREAT DEPRESSION/NEW DEAL (Ch. 11 & 12) Test

View Set

Ch. 18: Immunization and Vaccines

View Set