100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

C How To Program, 8th Edition By Deitel & deitel - Test Bank

Rating
-
Sold
-
Pages
209
Grade
A
Uploaded on
20-09-2023
Written in
2022/2023

3.1 Introduction (No Questions) 3.2 Algorithms 3.1 Specifying the order in which statements are to be executed in a computer program is called (a) an algorithm (b) transfer of control (c) program control (d) pseudocode ANS: (c) 3.2. The two key attributes of an algorithm are: a) actions and start activity b) flow and order of flow c) actions and order of actions d) flow and start activity ANS: (c) 3.3 Pseudocode 3.3 Which of the following is true of pseudocode programs? (a) they are executed by the computer (b) they help the programmer “think out” a program (c) they typically include definitions and all types of statements (d) all of the above are false ANS: (b) 3.4 Pseudocode does not typically include __________. (a) definitions (b) input/output (c) action statements (d) control statements ANS: (a) 3.5 Which statement is false? a) Pseudocode is an artificial and informal language that helps you develop algorithms. b) Pseudocode is similar to everyday English. c) Pseudocode is an actual programming language. d) Pseudocode programs are not actually executed on computers. ANS: (c) 3.6 Which statement is false? a) Pseudocode helps you “think out” a program before attempting to write it in a programming language such as C. b) Pseudocode programs consist purely of characters so program-mers may conveniently type pseudocode programs into a computer using an editor program. c) A carefully prepared pseudocode program is only a beginning; it still takes a tremendous amount of work to convert a pseudocode program into a C program. d) Pseudocode consists only of action statements. ANS: (c) 3.4 Control Structures 3.7 Which of the following encompasses the other three? (a) sequence structure (b) iteration structure (c) control structure (d) selection structure ANS: (c) 3.8 In a flowchart of an algorithm, what is the shape of the decision symbol? (a) circle (b) rectangle (c) diamond (d) rounded rectangle ANS: (c) 3.9 Which of the following is an iteration statement? (a) if (b) if…else (c) do…while (d) switch ANS: (c) 3.10 How many types of control statements exist in C? (a) 3 (b) 7 (c) 5 (d) 2 ANS: (a) 3.11 Normally, statements in a program are executed one after the other in the order in which they are written. This is called __________ execution. a) inline b) seeking c) ordered d) sequential ANS: (d) 3.12 Various C statements enable you to specify that the next state-ment to be executed may be other than the next one in sequence. This is called __________. a) change of order b) instruction skipping c) transfer of control d) rerouting ANS: (c) 3.13 Bohm and Jacopini’s work demonstrated that all programs could be written in terms of only three control statements, namely se-quence, __________ and iteration. a) selection b) serialization c) sorting d) searching ANS: (a) 3.14 Which statement is true? a) Unless directed otherwise, the computer automatically executes C statements one before the other. b) The sequence structure is essentially built into C. c) A flowchart is a pseudocode representation of an algorithm or a portion of an algorithm. d) Like pseudocode, flowcharts are useful for developing and repre-senting algorithms, although flowcharts are preferred by most pro-grammers. ANS: (b) 3.15 The __________ flowchart symbol is also called the action symbol. a) small circle b) diamond c) rounded rectangle d) rectangle ANS: (d) 3.16 Flowchart symbols are connected by arrows called __________. a) flowlines b) flow of control c) flow delimiters d) darts ANS: (a) 3.17 Small circle symbols in a flowchart are often called __________ symbols. a) little circle b) collision c) connector d) collator ANS: (c) 3.18 The diamond flowcharting symbol is also called the __________ symbol. a) determination b) derision c) declarative d) decision ANS: (d) 3.19 The __________ selection statement performs an action if a condi-tion is true and skips that action if the condition is false. a) if b) when c) if …else d) switch ANS: (a) 3.20 The __________ selection statement performs an action if a condi-tion is true and performs a different action if the condition is false. a) if b) when c) if…else d) switch ANS: (c) 3.21 The __________ selection statement performs one of many different actions, depending on the value of an expression. a) if b) when c) if…else d) switch ANS: (d) 3.22 The __________ is called a single-selection statement. a) if b) when c) if…else d) switch ANS: (a) 3.23 The __________ is called a double selection statement. a) if b) when c) if …else d) switch ANS: (c) 3.24 The __________ is called a multiple selection statement. a) if b) when c) if …else d) switch ANS: (d) 3.25 Which is not a C iteration statement? a) while b) do…while c) for d) do…for ANS: (d) 3.26 Which statement is true? a) Each of C’s control statements is characterized as being sin-gle-entry, single-exit. b) Each of C’s control statements is characterized as being sin-gle-entry, multiple-exit. c) Each of C’s control statements is characterized as being multi-ple-entry, single-exit. d) Each of C’s control statements is characterized as being multi-ple-entry, multiple-exit. ANS: (a) 3.27 Any C program we’ll ever need to build can be constructed from only __________ different control statements combined in only __________ ways. a) 7, 3 b) 6, 2 c) 7, 2 d) 6, 3 ANS: (c) 3.5 The if Selection Statement 3.28 If grade has the value of 60 what will the following code print? if (grade >= 60) { puts("Passed"); } (a) nothing (b) 60 (c) Passed (d) puts("Passed"); ANS: (c) 3.29 Indentation in the if selection statement is ________. (a) always mandatory (b) always optional (c) only mandatory if there is more than one statement following the if statement (d) only optional if there is more than one statement following the if statement ANS: (b) 3.30 The C compiler ignores __________ characters like blanks, tabs and newlines used for indentation and vertical spacing. a) transparent b) translucent c) white d) whitespace ANS: (d) 3.31 Which statement is true about the contents of a correct diamond symbol in a correct flowchart. a) It must contain an expression that evaluates to zero or one. b) It must contain a condition or expression that can be either true or false. c) It must contain relational operators. d) It must contain equality operators. ANS: (b) 3.32 A correct decision symbol has __________ flowlines emerging from it. a) 4 b) 3 c) 2 d) 1 ANS: (c) 3.33 Which of the following statements correctly prints “Passed” if the student’s grade is greater than or equal to 60 and “Failed” if the student’s grade is less than 60? [The quotes, of course, should not print.] a) printf("%sn", grade >= 60 : "Passed" : "Failed"); b) grade >= 60 : puts("Passed ") ? puts("Failed "); c) printf("%sn", grade >= 60 ? "Passed" : "Failed"); d) grade >= 60 ? puts("Passed ") ? puts("Failed "); ANS: (c) 3.34 Which statement is false? a) A compound statement can be placed anywhere in a program that a single statement can be placed. b) The if selection statement can have only one statement in its body. c) A set of statements contained within a pair of braces ({ and }) is called a compound statement. d) An if slection statement can have a compound statement in its body. ANS: (b) 3.6 The if…else Selection Statement 3.35 The conditional operator (?:) ________. (a) is the only ternary operator in C (b) is a unary operator (c) associates from left to right (d) accepts two operands ANS: (a) 3.36 Which of the following will generate an error? (a) if (answer == 7) { puts("correct"); } else { puts("incorrect"); } (b) puts(answer == 7 ? "correct" : "incorrect"); (c) printf("%sn", answer == 7 ? "correct" : "incor-rect"); (d) answer == 7 ? puts("correct") : puts("incorrect"); ANS: (b) 3.37 A statement is called a block if it ________. (a) is a compound statement (b) contains definitions (c) is a compound statement that contains definitions (d) does not contain definitions ANS: (c) 3.38 Placing a semicolon after the parenthesized condition in an if statement leads to a __________ error in single-selection if statements and a __________ error in double-selection if statements. a) logic, logic b) logic, syntax c) syntax, logic d) syntax, syntax ANS: (b) 3.39 The empty statement is represented by placing __________ where a statement would normally be. a) empty b) ; c) null d) : ANS: (b) 3.7 The while Iteration Statement 3.40 What is wrong with the following loop? While (sum <= 1000) { sum = sum + 30; } (a) The parenthesis should be braces. (b) The braces around sum = sum +30; should be removed. (c) While should be while. (d) There should be a semicolon after While (sum <=1000). ANS: (c) 3.41 How many times will the following program print hello? i = 1; while (i <= 10) { puts("hello"); } (a) 10 (b) 8 (c) an infinite number of times (d) 0 ANS: (c) 3.42 Consider the following correct segment of a correct C program: p = 2; while (p < 2000) { p = 2 * p; } What is the value of p after this while loop completes its execution? a) 1023 b) 1024 c) 2047 d) 2048 ANS: (d) 3.8 Formulating Algorithms Case Study 1: Counter-Controlled Iteration 3.43 An uninitialized variable contains ________. (a) the value last stored in the memory location reserved for that variable (b) no value (c) a value of zero (d) a randomly assigned value ANS: (a) 3.44 Counter-controlled iteration is often called __________ iteration because the number of iterations is known before the loop begins executing. a) indefinite b) sentinel c) definite d) determinate ANS: (c) 3.9 Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 2: Sentinel-Controlled Iteration 3.45 Indefinite iteration is controlled by a (a) counter (b) sentinel value (c) data value (d) non-constant condition ANS: (b) 3.46 A fatal logic error is always caused by: (a) not initializing variables before executing an iteration statement (b) choosing a sentinel value that is also a data value (c) using a counter variable in a calculation after the loop (d) an attempt to divide by zero ANS: (d) 3.47 In indefinite iteration, an input value (a) should always be evaluated before being processed (b) should always be processed directly after it is entered (c) should never be modified (d) can be entered, processed, and evaluated in any order ANS: (a) 3.48 What is the final value of x after performing the following oper-ations? int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y; (a) 8.25 (b) 5.5 (c) 5 (d) 8 ANS: (d) 3.49 Which operation does not take place in the following example? int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y; (a) implicit conversion (b) promotion (c) explicit conversion (d) truncation ANS: (c) 3.50 Which of the following is not a synonym for “sentinel value.” a) signal value b) dummy value c) counter value d) flag value ANS: (c) 3.10 Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 3: Nested Control Statements 3.51 Having a loop within a loop is known as (a) recursion (b) doubling up (c) nesting (d) a redundancy ANS: (c) 3.52 Which statement is true? a) With nested control statements, the inner control statement is ex-ecuted in sequence after the outer control statement completes its own execution. b) With nested control statements, the inner control statement is ex-ecuted exactly once. c) Experience has shown that the most difficult part of solving a problem on a computer is converting an already correct algoithm to a C program. d) A double-selection statement can be nested in an iteration state-ment. ANS: (d) 3.11 Assignment Operators 3.53 If x = 3, which of the following sets x to 7? (a) x *= 4; (b) x += 4; (c) x =+ 4; (d) x + 4 = x; ANS: (b) 3.54 Which assignment expression is equivalent to c = c / 2 ? (a) c / = 2 (b) c / c = 2 (c) c /= 2 (d) c =/ 2 ANS: (c) 3.12 Increment and Decrement Operators 3.55 Which of the following will not increment variable c by one? (a) c + 1; (b) c++; (c) ++c; (d) c += 1; ANS: (a) 3.56 In which of the following is y not equal to 5 after execution? Assume that x is equal to 4. (a) y = 5; (b) y = x++; (c) y = ++x; (d) y = x = 5; ANS: (b) 3.57 Which statement is true? a) The expression ++(a + 1) adds 2 to a. b) The expression **a multiplies a by 1. c) The ANSI standard for the C programming language specifies the order in which each operator’s operands will be evaluated. d) The expression --(abc * 37) is a syntax error ANS: (d) 3.13 Secure C Programming 3.58 Which of the following statements is true about undefined be-havior, which can leave a system open to attack? (a) It’s not possible to have undefined behavior when adding two integers. (b) Adding two integers can result in arithmetic overflow, which can cause undefined behavior. (c) You should not worry about undefined behavior in your pro-grams. (d) None of the above. ANS: (b) 3.59 Which of the following statements is true? (a) A counter variable that stores only non-negative numbers should be declared as an unsigned integral type. (b) A counter variables that stores only non-negative numbers should be declared as a signed integral type. (c) The type of a counter does not matter (d) None of the above. ANS: (a) 6.1 Introduction 6.1 Arrays are data structures consisting of related data items of the same __________. a) sort order b) subscript c) type d) element ANS: (c) 6.2 Arrays and structures are __________ entities in that they remain the same size throughout program execution. a) dynamic b) automatic c) register d) static ANS: (d) 6.3 Lists, queues, stacks and trees are __________ data structures that may grow and shrink as programs execute. a) flexible b) automatic c) dynamic d) static ANS: (c) 6.2 Arrays 6.4 An array is not ________. (a) a consecutive group of memory locations (b) indexed by integers (c) pointer-based (d) a dynamic entity ANS: (d) 6.5 Which of the following is false? (a) the first element of an array is the zeroth (b) the last element of an array is the array size - 1 (c) the position number contained within square brackets is called a subscript (d) a subscript cannot be an expression. ANS: (d) 6.6 An array is a group of memory locations related by the fact that they all have __________ array name and __________ type. a) different, different b) same, different c) different same d) same, same ANS: (d) 6.7 The first element in every array is the __________ element. a) null b) 1 c) 0 d) empty ANS: (c) 6.8 Which statement is false? a) The brackets used to enclose the subscript of an array are not an operator in C. b) To refer to a particular element in an array, we specify the name of the array and the position number of the element in the array. c) The position number within an array is more formally called a subscript. d) “Array element seven” and the “seventh element of an array” do not mean the same thing. This is a frequent source of off-by-one errors. ANS: (a) 6.3 Defining Arrays 6.9 Which statement would be used to define a 10 element integer array c? (a) Array c = int[10]; (b) c = int[10]; (c) int Array c[10]; (d) int c[10]; ANS: (d) 6.10 Which definition tells the computer to reserve 12 elements for integer array c? a) c[12] int; b) int c [11]; c) c[11] int; d) int c[12]; ANS: (d) 6.4 Array Examples 6.11 Which of the following is not a correct way to initialize an array? (a) int n[5] = {0, 7, 0, 3, 8, 2}; (b) int n[] = {0, 7, 0, 3, 8, 2}; (c) int n[5] = {7}; (d) int n[5] = {6, 6, 6}; ANS: (a) 6.12 Constant variables (a) can be assigned values in executable statements (b) do not have to be initialized when they are defined (c) can be used to specify array sizes, thereby making programs more scalable (d) can be used to specify array sizes, but this makes programs harder to understand ANS: (c) 6.13 Referencing elements outside the array bounds (a) can result in changes to the value of an unrelated variable (b) is impossible because C checks to make sure it does not happen (c) is a syntax error (d) enlarges the size of the array ANS: (a) 6.14 Strings can not (a) be initialized using string literals (b) end in a character other than the null character (c) be initialized with initializer lists (d) be treated as arrays of characters ANS: (b) 6.15 Assume string1 is a character array. Which of the following operations does not produce a string? (a) string1[] = "test"; (b) string1[] = {'t', 'e', 's', 't', '0'}; (c) string1[] = {'t', 'e', 's', 't'}; (d) string1[] = " "; ANS: (c) 6.16 Suppose a program contains the code for (i = 1; i < = 10; i++) { n[i] = 0; } Which statement about this code must be true? a) It contains an off-by-one error. b) It contains a syntax error. c) It is initializing the first 10 elements of an array. d) It is initializing successive elements of an array. ANS: (d) 6.17 What’s wrong with this code? int[] = (1, 2, 3, 4, 5); a) The array size must be specified in the square brackets. b) The parentheses should be square brackets. c) The square brackets should be curly braces. d) The parentheses should be curly braces. ANS: (d) 6.18 If there are fewer initializers than elements in the array, the remaining elements are __________. a) deleted b) ignored c) initialized to empty d) initialized to zero ANS: (d) 6.19 Which statement is true? a) Arrays are automatically initialized to zero. b) To initialize all array elements to zeros, the array definition must explicitly initialize each element to zero. c) Array elements can be initialized to zero by the array definition only at compile time. d) Definitions for automatic arrays initialize the arrays at execution time. ANS: (d) 6.20 The following array definition int n[5] = {32, 27, 64, 18, 95, 14}; a) is correct b) causes a syntax error because there are only five initializers and six array elements. c) causes a logic error because there are only five elements but there are six initializers. d) causes a syntax error because there are six initializers but only five array elements. ANS: (d) 6.21 Which statement is true? a) A symbolic constant is an identifier that is replaced with replacement text by the C preprocessor after the program is compiled. b) Using symbolic constants to specify array sizes makes programs run faster. c) Preprocessor directives are not C statements. d) The #define preprocessor directive must end in a semicolon. ANS: (c) 6.22 Which statement is true? a) Assigning a value to a symbolic constant in an executable statement is a syntax error. b) A symbolic constant is a variable. c) Space is reserved for both symbolic constants and variables that hold values at execution time. d) Only uppercase letters can be used for symbolic constant names. ANS: (a) 6.23 Which statement is true regarding the statement ++frequency[responses[answer]]; a) This statement increases the appropriate frequency counter depending on the value of responses[answer]. b) This statement increases the appropriate answer counter depending on the value of frequency[responses]. c) This statement increases the appropriate responses counter depending on the value of frequency[answer]. d) This statement produces a syntax error because subscripts cannot be nested. ANS: (a) 6.24 Which statement is false? a) C has no built-in bounds checking to prevent the computer from referring to an array element that does not exist. b) The programmer is responsible for implementing array bounds checking. c) Referring to an element outside the array bounds is a syntax error. d) Referring to an element outside the array bounds is a logic error. ANS: (d) 6.5 Using Character Arrays to Store and Manipulate Strings 6.25 Which statement is false? a) The string termination character is called the null character. b) The string “string” actually occupies 7 characters in memory. c) The character representation of the last character in memory of a string is ‘0’. d) A character array representing a string should be defined as large as the actual number of characters in the string minus the terminating character; C automatically provides the space for the terminating character. ANS: (d) 6.26 The definition char string1[] = "first"; is equivalent to: a) character string1[] = {'f', 'i', 'r', 's', 't', '0'}; b) char string1 = {'f', 'i', 'r', 's', 't', '0'}; c) char string1[] = {'f', 'i', 'r', 's', 't'}; d) char string1[] = {'f', 'i', 'r', 's', 't', '0'}; ANS: (d) 6.27 Which statement is false? a) Function scanf reads characters into memory from the keyboard until the first input whitespace character is encountered. b) Function scanf can write beyond the boundary of the array into which input is being placed. c) Function printf does not care how large the array it is printing is. d) When using scanf, you must always precede with the & operator the name of each variable into which inputs are being placed. ANS: (d) 6.6 Static Local Arrays and Automatic Local Arrays 6.28 Which statement is false? a) A static local variable exists for the duration of the program. b) A static local variable is visible only in the control structure in which it is defined. c) A static local array is not created and destroyed each time the function is entered and exited, respectively. d) Arrays that are defined static are automatically initialized once at compile time. ANS: (b) 6.7 Passing Arrays to Functions 6.29 Unless otherwise specified, entire arrays are passed __________ and individual array elements are passed __________. (a) call-by-value, call-by-reference (b) call-by-reference, call-by-value (c) call-by-value, call-by-value (d) call-by-reference, call-by-reference ANS: (b) 6.30 Which of the following is false about a function being passed an array? (a) it knows the size of the array it was passed (b) it is passed the address of the first element in the array (c) it is able to modify the values stored in the array (d) all of the above are true ANS: (a) 6.31 To prevent modification of array values in a function, (a) the array must be defined static in the function. (b) the array parameter can be preceded by the const qualifier. (c) a copy of the array must be made inside the function. (d) the array must be passed call-by-reference. ANS: (b) 6.32 To pass an array to a function, specify a) the name of the array without any brackets. b) the name of the array preceded by an empty pair of brackets. c) the name of the array followed by a pair of brackets including the size of the array. d) the name of the array followed by a pair of brackets including a number one less than the size of the array. ANS: (a) 6.33 Which statement is false? a) C automatically passes arrays to functions using simulated call by reference. b) When C passes an array to a function, the called function normally can modify the element values in the caller’s original array. c) The name of an array is actually the address of the first element of the array. d) When an array is passed in a function call, the calling function knows precisely where in the called function’s memory the passed array is. ANS: (d) 6.34 The special conversion specifier for printing addresses is __________. a) %a b) %m c) %p d) %loc ANS: (c) 6.35 Which statement is true? a) Entire arrays are passed simulated call by reference and individual array elements are normally passed simulated call by reference. b) Entire arrays are passed simulated call by reference and individual array elements are normally passed call by value. c) Entire arrays are passed call by value and individual array elements are normally passed simulated call by reference. d) Entire arrays are passed call by value and individual array elements are normally passed call by value. ANS: (b) 6.8 Sorting Arrays 6.36 Which statement about bubble sort is true? (a) a maximum of n passes are needed to sort the array, where n is the number of elements (b) swapping values requires two assignments (c) performance is maximized (d) the algorithm is very simple compared to other sorting procedures ANS: (d) 6.37 Which statement about the bubble sort is false? a) It is easy to program. b) It is a high-performance sort. c) It compares only adjacent elements with one another. d) The bubble sort compares successive pairs of elements. ANS: (b) 6.38 A bubble sort of 1000 elements requires a maximum of __________ passes. a) 1001 b) 1000 c) 999 d) 998 ANS: (c) 6.9 Case Study: Computing Mean, Median and Mode Using Arrays 6.39 In order to calculate the __________ of an array of values, the array must be sorted. (a) median (b) mode (c) mean (d) (a), (b), and (c) ANS: (a) 6.40 The _____ is the average value of a set of data items. a) mean b) median c) mode d) matrix ANS: (a) 6.41 Calculating which of the following normally requires the data to be sorted first a) mean b) median c) mode d) total ANS: (b) 6.42 The __________ is the value that occurs most frequently in the data. a) mean b) median c) mode d) master ANS: (c) 6.10 Searching Arrays 6.43 The binary search technique (a) is better suited to small arrays (b) is better suited to unsorted arrays (c) can only be used on a sorted array (d) is slower than a linear search ANS: (c) 6.44 The maximum number of comparisons needed for the binary search of a 2000 element array is (a) 9 (b) 15 (c) 11 (d) 14 ANS: (c) 6.45 Which of these is generally thought of as a high-performance technique? a) bubble sort b) linear search c) binary search d) iteration ANS: (c) 6.46 Which of the following statements is false? a) The linear searching method works well for small arrays. b) The linear searching method works well for unsorted arrays. c) The binary search algorithm eliminates from consideration one half of the elements in a sorted array after each comparison. d) The binary search terminates only when the search key is equal to the middle element of a subarray. ANS: (d) 6.47 A sorted array of a million elements can be searched by a binary search in __________ or fewer comparisons. a) 10 b) 20 c) 30 d) 999,999 ANS: (b) 6.11 Multidimensional Arrays 6.48 A two-dimensional array element incorrectly referenced as a[x, y] is actually evaluated as (a) a[x][y] (b) a[y] (c) a[x] (d) a[0] ANS: (b) 6.49 Given the following definitions, what is the value of b[1][0]? int b[2][2] = {{1}, {3, 4}}; (a) 0 (b) 1 (c) 3 (d) this isn’t a valid definition ANS: (c) 6.50 Which of the following does not initialize all of the array elements to 0? (a) int b[2][2]; b[0][0] = b[0][1] = b[1][0] = b[1][1] = 0; (b) int b[2][2] = {0}; (c) int b[2][2]; for (int i = 0; i < 2; ++i) { for (int j = 0; j < 2; ++j) { b[i][j] = 0; } } (d) all of the above initialize all of their elements to 0. ANS: (d) 6.51 Which statement is false about multidimensional arrays? a) C supports multidimensional arrays. b) A common use of multidimensional arrays is to arrange data into tables consisting of rows and columns. c) To identify a particular table element requires two indices. d) Every ANSI C system can support arrays with as many indices as the programmer chooses. ANS: (d) 6.52 An array containing 3 columns and 4 rows is typically referred to as a __________. a) 12-element array b) 3-by-4 array c) 13-element array, because of the zero element d) 4-by-3 array ANS: (d) 6.53 Which initialization is not performed by the following definition? int b[2][2] = {{1}, {3, 4}}; a)b[0][0] is set to 1 b) b[0][1] is set to 1 c) b[1][0] is set to 3 d) b[1][1] is set to 4 ANS: (b) 6.12 Variable-Length Arrays No questions. 6.13 Secure C Programming 6.54 Which of the following statements is false? (a) C provides automatic bounds checking for arrays. (b) C provides no automatic bounds checking for arrays, so you must provide your own. (c) Allowing programs to read from or write to array elements outside the bounds of arrays are common security flaws. (d) Writing to an out-of-bounds element (known as a buffer overflow) can corrupt a program’s data in memory, crash a program and allow attackers to exploit the system and execute their own code. ANS: (a) 6.55 Assuming myString is a 20-element char array, which of the following statements might result in buffer overflow? (a) scanf("%19s", myString); (b) scanf_s("%s", myString, 20); (c) scanf_s("%19s", myString, 20); (d) scanf("%s", myString); ANS: (d) c how to program - test bank, c programming question bank pdf, programming logic test examples, c program coding questions, c coding rules, how to test c program, c programming question bank with answers pdf,

Show more Read less











Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
September 20, 2023
Number of pages
209
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

,1.1 Introduction

1.1 Which of the following statements is true?
(a) hardware controls software
(b) software commands the computer to perform actions and make decisions
(c) C is an object oriented programming language
(d) Both (b) and (c)
ANS: (b)

1.2 Which of the following is going to be the key programming methodology for the
next decade?
(a) object-oriented programming
(b) structured programming
(c) “legacy C code”
(d) “live-code approach”
ANS: (a)



1.2 Hardware and Software
1.3 Today's fastest computers are called __________.
(a) mega computers
(b) terminals
(c) supercomputers
(d) CPUs
ANS: (c)

1.4 Which of the following would not be considered hardware?
(a) an operating system
(b) a CPU
(c) a keyboard
(d) a disk
ANS: (a)

1.5 Computer programs are __________.
(a) sequences of instructions
(b) the information processed by the computer
(c) the various devices (disks, memory, keyboard) that comprise a computer system
(d) the people programming the computers
ANS: (a)

1.2.1 Moore’s Law
1.6 Which of the following is most closely associated with Moore's Law?
(a) Every year or two, the price of computers has approximately doubled.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.

,(b) Object-oriented programming uses less memory than previous software-
development methodologies.
(c) Demand for communications bandwidth is decreasing dramatically each year.
(d) Every year or two, the capacities of computers have approximately doubled
without any increase in price.
ANS: (d) Every year or two, the capacities of computers have approximately doubled
without any increase in price.

1.2.2 Computer Organization
1.7 Which of the following is not one of the six logical units of a computer?
(a) input unit
(b) programmer unit
(c) memory unit
(d) output unit
ANS: (b)

1.8 Programs or data not actively being used by the other units are placed on the
__________.
(a) output unit.
(b) memory unit.
(c) secondary storage unit.
(d) central processing unit.
ANS: (c)

1.3 Data Hierarchy
1.9 The smallest data item in a computer, called a ________, can assume the value 0 or
the value 1.
(a) bit
(b) character
(c) field
(d) digit
ANS: (a)

1.10 A ________ is a group of characters or bytes that conveys meaning.
(a) database
(b) record
(c) character set
(d) field
ANS: (d)

1.11 A ________ is an electronic collection of data that’s organized for easy access and
manipulation.
(a) field
(b) database
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.

, (c) record
(d) file
ANS: (b)

1.4 Machine Languages, Assembly Languages and High-Level Languages
1.12 Which of the following is not one of the three general types of computer
languages?
(a) Machine languages.
(b) Assembly languages.
(c) High-Level languages.
(d) Spoken languages.
ANS: (d) Spoken languages.

1.13 Which of the following statements is true?
(a) Interpreted programs run faster than compiled programs.
(b) Compilers translate high-level language programs into machine language
programs.
(c) Interpreter programs typically use machine language as input.
(d) None of the above.
ANS: (b) Compilers translate high-level language programs into machine language
programs.

1.14 A computer can directly understand only its own ___________.
(a) machine language
(b) assembly language
(c) high-level language
(d) none of the above
ANS: (a)

1.15 Assemblers__________.
(a) convert machine language into high-level language.
(b) convert assembly language into machine language.
(c) convert high-level language into machine language.
(d) convert high-level language into assembler language.
ANS: (b)

1.16 Programs that directly execute high-level language programs without
compiling are called __________.
(a) assemblers
(b) interpreters
(c) compilers
(d) translators
ANS: (b)


© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ExamsExpert (self)
View profile
Follow You need to be logged in order to follow users or courses
Sold
617
Member since
2 year
Number of followers
313
Documents
2838
Last sold
5 days ago
ExamsExpert

We as a team provide best and Latest Test Banks that helps students to get A Grade we have vast range of test banks you can order us any test bank that you need

4.5

85 reviews

5
58
4
15
3
9
2
1
1
2

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions