CS 159 Exam 02 Crum

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which of the following statements regarding nested if constructs is FALSE? A. Proper indentation of else if and else will determine to which if they belong in a nested construct. B. Nested if constructs are different from multi-way selection in that nested if constructs will typically test different variables. C. While there is no limit to the number of levels of nesting in a nested if construct, a larger number of levels may make the code difficult to read D. None of the above

A

6. Given the array below 73 70 77 74 72 71 which of the following is NOT a possible configuration of the array after two passes through the selection sorting algorithm? A. 72 70 71 73 74 77 B. 70 71 77 74 72 73 C. 77 74 73 70 72 71 D. None of the above.

A. 72 70 71 73 74 77

Which of the following statements regarding repetition is TRUE? A Input validation is an example of an event-controlled problem. B In this course you will be expected to validate for the input of both the range of acceptable values and the correct data type. C In order for two, or more, repetitive processes to be considered nested they must appear in the same user-defined function. D None of the above.

A. Input validation is an example of an event-controlled problem.

Given the array below and a target of 52, 51 54 58 59 63 65 66 70 71 74 which of the following represents the final values of the first and last variables when the binary search is applied? A. first = 1, last = 0 B. first = 0, last = 0 C. first = 0, last = -1 D. None of the above

A. first = 1, last = 0

Which of the following statements regarding the conditional expression is TRUE? A. Both executable actions of a conditional expression will terminate with a semicolon. B. The conditional expression has a total of two operators and three operands. C. A conditional expression cannot have another conditional expression as one of its executable actions D. None of the above.

B

Given the array below and a target of 25, 16 16 17 19 19 20 24 24 25 25 25 25 which of the following represents the value of the mid variable as the binary search is applied? A. 5, 8, 9 B. 5, 8, 10 C. 6, 9 D. None of the above

B. 5, 8, 10

Which of the following statements regarding looping constructs is FALSE? A Immediately following the update action of a for loop will be the evaluation of the loop control expression. B The initialization of the loop control variable must take place outside the body of a do-while loop. C In a while loop the number of times the loop control expression is evaluated is one more than the number of times the loop will iterate. D None of the above.

B. The initialization of the loop control variable must take place outside the body of a do-while loop.

Given the array below and a target of 75, 51 54 58 59 63 65 66 70 71 74 which of the following represents the final values of the first and last variables when the binary search is applied? A. first = 9, last = 8 B. first = 10, last = 9 C. first = 9, last = 9 D. None of the above

B. first = 10, last = 9

Assuming that variables x and y are non-negative integers, which of the following is the complement to the expression below? x % 2 && y % 2 A x % 2 == 0 && y % 2 == 0 B x % 2 == 0 || y % 2 == 0 C x % 2 != 0 || x % 2 != 0 D None of the above.

B. x % 2 == 0 || y % 2 == 0

Which of the following statements regarding redirection of external data into an executable program is FALSE? A. The redirection of output (>) will replace and existing contents in the destination file. B. The redirection of output does not also require the redirection of input. C. The redirection of output (>>) will result in an error when the destination file does not yet exist. D. None of the above.

C

Which of the following statements regarding the course programming and documentation standards is FALSE? A. The use of the break must be limited to within the switch construct. B. The use of { and } is requires with all relevant selection and repetition constructs. C. The variables that are parameters to a function are commented to the right of where they are declared in the first line of the function definitions. D. None of the above.

C

Which of the following statements regarding the for loop construct is FALSE? A. The compiler requires that the loop control variable be declared before any of the three for loop expressions are evaluated. B. The loop control variable is typically the recipient of the initialization expression of a for loop. C. The update expression is executed prior to every iteration of a for loop. D. None of the above.

C

Which of the following statements regarding the short-circuit method of evaluating logical expressions is TRUE? A. The result of a logical expression will change depending on whether or not a short-circuit occurs or not. B. The short-circuit method is limited to use with those logical expressions containing relational or equality operators. C. The evaluation of a loop control expression will include the short-circuit method when relevant. D. None of the above.

C

Which of the following statements regarding the techniques of repetition and standards of the course is FALSE? A. According to the standards of the course the use of recursion should be limited to counter-controlled processes B. The omission of one or more of the three expressions from a for loop is a violation of course standards. C. The use of a for loop construct is preferred to a while loop construct and course standards suggest converting from a while to for when possible. D. None of the above

C

Given the array below and a target of 24, 16 16 17 19 19 20 24 24 25 25 25 25 which of the following represents the value of the mid variable as the binary search is applied? A. 5, 8 B. 6 C. 5, 8, 6 D. None of the above

C. 5, 8, 6

Given the array below 73 70 77 74 72 71 which of the following is NOT a possible configuration of the array after two passes through the bubble sorting algorithm? A 70 73 72 71 74 77 B 77 74 73 72 71 70 C 70 71 73 72 74 77 D None of the above.

C. 70 71 73 72 74 77

Which of the following statements regarding logical expressions is FALSE? A When attempting to print the result of a logical expression that is true as an integer the result will always be 1. B Complementing a condition is one way to potentially remove negative logic from an expression. C A logical expression cannot be used as the control expression of a switch construct. D None of the above.

C. A logical expression cannot be used as the control expression of a switch construct.

Which of the following statements regarding the switch construct is FALSE? A The switch case label represents an integral type that is a potential result of the control expression. B No two switch case labels can represent the same constant expression value. C The maximum number of actions that can be associated with a switch case label is one. D None of the above.

C. The maximum number of actions that can be associated with a switch case label is one.

Which of the following statements regarding arrays is FALSE? A The address operator is necessary in a scanf to accept input for an individual array element when using the indexing technique. B When accessing an array element the C language does not check whether the index is within the boundary of an array. C Using the name of an integer array in the data list of a single printf function will result in the output of all elements of the array. D None of the above.

C. Using the name of an integer array in the data list of a single printf function will result in the output of all elements of the array.

Given x is a positive integer variable, which of the following expressions will generate a value in the range from 1 to x inclusive of the end points? A rand() % x B rand() % (x + 1) C rand() % x + 1 D None of the above.

C. rand() % x + 1

Which of the following statements regarding the input validation expectations of the course is FALSE? A. The code associated with input validation is commonly found in the same function that accepts the input from the user. B. Expectations to handle the validation of input are only within a type of data that is specified on an assignment. C. The use of pass by address for multiple variables in a single input function is discouraged as the function will become unnecessarily long and complex with the addition of the input validation code. D. None of the above.

D

Which of the following statements regarding the rules of the switch construct is TRUE? A. Two case labels can have the same constant expression value. B. No two case labels can be associated with the same set of actions. C. The control expression that follows the keyword switch must be a numeric type. D. None of the above.

D

Given the array below 73 70 77 74 72 71 which of the following is NOT a possible configuration of the array after two passes through the insertion sorting algorithm? A. 73 70 77 71 72 74 B. 70 73 77 74 72 71 C. 77 73 70 74 72 71 D. None of the above

D. None of the above

Which of the following statements regarding recursion is FALSE? A Recursion should not be used with event-controlled processes as the result may be more function calls than the memory of the computer can accommodate. B The condition when a recursive function makes no further function calls is known as the base case. C A recursive function is not required to be a void function. D None of the above.

D. None of the above

(a != 0) and !(a == 0) are complementary logical expressions (the variable a is an integer).

False

A variable declared in the local declaration section of a function can have the same identifier as one of the parameters of the same function.

False

All function declarations found in your program will appear inside of the main function.

False

An iterative solution is one that is implemented using a function that calls itself.

False

Conditional expressions cannot be nested as the resulting code becomes too complex.

False

In a pretest loop the number of times the loop control expression is evaluated is equal to the number of iterations.

False

In order for two, or more, repetitive processes to be considered nested they must appear in the same user-defined function.

False

It is not possible to determine if any parameters are passed to a function by address from the declaration statement of the function.

False

It is not possible to update the loop control variable of a for loop inside of its body.

False

The condition in a recursion when which the recursive function calls stop is known as the recursive case.

False

The gcc compiler as used on the guru.itap.purdue.edu server this semester will permit a variable to be declared and initialized in the first expression of a for loop.

False

The logical OR operator is true only when exactly one of its operands is true.

False

The redirection of output with two greater than characters will replace any existing contents in the destination file.

False

The role of the main function is to coordinate the function calls, to establish the data needs, and generate output for a program.

False

The short-circuit method of evaluating logical expressions is only relevant to those expressions that make use of at least one relational operator.

False

To obtain the address of a variable we use the asterisk operator (*).

False

When the statements associated with one case have been executed the program flow continues with next statement following the end of the switch construct.

False

(a != 0) and !(a) are complementary logical expressions (the variable a is an integer).

True

A counter-controlled loop may execute a constant number of iterations.

True

A function may return at most one value.

True

A structure chart may show the data that is exchanged between functions.

True

Evaluate the following expression: 0 && 3 || 6

True

In downward communication it is only a copy of the data that is sent to the function.

True

It is a course standard to indent all code within the body of relevant selection constructs two additional spaces.

True

It is a good design practice to create a user-defined function such that it is testable apart from the rest of the program.

True

Not every function that utilizes pass by address are necessarily void functions.

True

Objects with a global scope are visible (defined) everywhere in the program.

True

The called function must declare a special type of variable known as a pointer to store a memory address that is sent from the calling function.

True

The complement of x > 3 is x <= 3

True

The control of the program always returns from the called function to the calling function.

True

The function call is an executable statement.

True

The function definition contains executable statements that perform the task of the function. A) True B) False

True

The loop control variable is commonly a part of the loop control expression and the recipient of the loop update action.

True

The tail command can include an optional number to display exactly the specified number of lines at the end of a file.

True

The void in the following declaration statement would be optional: int getData(void);

True

There is no semi-colon following the logical expression of an if...else construct.

True

When different variables are being evaluated it is better to use a nested if-else rather than the multiway else-if.

True

Assuming that variables x and y are non-negative integers, which of the following is the complement to the expression below? x == 1 || x == 0 && y == 0 || y == 1 A x != 1 && x != 0 || y != 0 && y != 1 B x != 1 && (x || y) && y != 1 C !(x != 1 || x != 0 && y != 0 || y != 1) D None of the above.

x != 1 && (x || y) && y != 1


संबंधित स्टडी सेट्स

Chapter: Policy Riders, Provisions, Options and Exclusions

View Set

India Under British Rule:Pre-Test

View Set

Chapter 7: The Solar System Lesson 2: What Is the Solar System?

View Set

Patient Care Chp 18 Aseptic Techniques

View Set

Psych - Ch 10, 11, 12, 13, 14, 15

View Set

CIS 105: Module 5 Software and Apps Exam

View Set

Kill the Indian and Save the Man

View Set