Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

COP 3363 - Introduction to Programming (with C++ and Unix) Exam 3 Prep, Exams of C programming

COP 3363 - Introduction to Programming (with C++ and Unix COP 3363 - Introduction to Programming (with C++ and Unix) Exam 3 Prep

Typology: Exams

2024/2025

Available from 06/18/2025

Fortis-In-Re
Fortis-In-Re šŸ‡ŗšŸ‡ø

1

(1)

2.3K documents

1 / 26

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COP 3363 - Introduction to Programming (with C++ and
Unix) Exam 3 Prep
1 / 26
1. A volatile type of memory that is used for temporary storage is
A) RAM
B) a disk drive
C) an address
D) the ALU
E) None of these: RAM
2. Which of the following best describes an operator?
A) An operator is a word that has special meaning
B) An operator marks the beginning or ending of a statement, or is used to
separate items in a list
C) An operator is a rule that must be followed when constructing a program
D) An operator allows you to perform operations on one or more pieces of
data
E) An operator is a symbolic name that refers to a variable: An operator allows
you to perform operations on one or more pieces of data
3. A named storage location in the computer's memory that holds a piece of
information is a(n):
A) statement
B) operator
C) key word
D) variable
E) None of these: variable
4. The programmer usually enters source code into a computer with
A) a compiler
B) a hierarchy chart
C) a text editor
D) pseudocode
E) None of these: a text editor
5. The CPU's control unit retrieves the next instruction in a sequence of
program instructions from main memory in the stage.
A) decode
B) fetch
C) execute
D) portability: fetch
6. A model often used when creating a program that begins with the overall
task and refines it into smaller subtasks is a(n)
A) hierarchy chart
B) UML Diagram
C) blueprint
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download COP 3363 - Introduction to Programming (with C++ and Unix) Exam 3 Prep and more Exams C programming in PDF only on Docsity!

Unix) Exam 3 Prep

  1. A volatile type of memory that is used for temporary storage is A) RAM B) a disk drive C) an address D) the ALU E) None of these: RAM
  2. Which of the following best describes an operator? A) An operator is a word that has special meaning B) An operator marks the beginning or ending of a statement, or is used to separate items in a list C) An operator is a rule that must be followed when constructing a program D) An operator allows you to perform operations on one or more pieces of data E) An operator is a symbolic name that refers to a variable: An operator allows you to perform operations on one or more pieces of data
  3. A named storage location in the computer's memory that holds a piece of information is a(n): A) statement B) operator C) key word D) variable E) None of these: variable
  4. The programmer usually enters source code into a computer with A) a compiler B) a hierarchy chart C) a text editor D) pseudocode E) None of these: a text editor
  5. The CPU's control unit retrieves the next instruction in a sequence of program instructions from main memory in the stage. A) decode B) fetch C) execute D) portability: fetch
  6. A model often used when creating a program that begins with the overall task and refines it into smaller subtasks is a(n) A) hierarchy chart B) UML Diagram C) blueprint

Unix) Exam 3 Prep

D) flowchart E) None of these: hierarchy chart

  1. This is used in a program to mark the beginning or ending of a statement, or separate items in a list: A) key words B) separators C) punctuation D) operators E) None of these: punctuation
  2. A computer stores a program while it is running A) on a hard disk B) on the computer monitor C) in the CPU D) in main memory E) None of these: in main memory
  3. This is a set of rules that must be followed when constructing a program: A) identifiers B) syntax C) key words D) operators E) punctuation: syntax
  4. At the heart of a computer is its central processing unit. The CPU's job is: A) to carry out the operations commanded by the instructions B) to fetch instructions C) to produce some outcome or resultant information D) All of these E) None of these: All of these
  5. In a C++ program, two slash marks (//) indicate A) the beginning of a comment B) the beginning of a block of code C) the end of a statement D) the end of a program E) None of these: the beginning of a comment
  6. Character constants in C++ are always enclosed in A) braces ({}) B) brackets (<>) C) pound sign and semicolon (#;) D) single quotation marks ('') E) Any of these: single quotation marks ('')

Unix) Exam 3 Prep

  1. You must have a for every variable you intend to use in a program. A) purpose B) literal value C) memory space D) variable definition E) None of these: variable definition
  2. Assuming that a program has the following string object definition, which statement correctly assigns the string literal "Jane" to the string object? string name; A) name = ; B) name = Jane; C) string name = {Jane}; D) name = 'Jane'; E) name = "Jane";: name = "Jane";
  3. To use the rand() function, you must include the header file? A) cstring B) cstdlib C) iomanip D) iostream E) cmath: cstdlib
  4. What is the value of x after the following code executes? int x = 0; int y = 5; int z = 4; x = x + y + z * 2; A) 0 B) 26 C) 13 D) 18 E) unknown: 13
  5. You can control the number of significant digits in your output with the manipulator A) to_fixed B) setfixed() C) setprecision D) set_precision E) None of these: setprecision

Unix) Exam 3 Prep

  1. 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 } A) line 9 B) line 8 C) line 6 D) line 7 E) there will be no compiler error: line 7
  2. This manipulator forces cout to print digits in fixed-point notation: A) fixed B) setfixed(2) C) setprecision(2) D) setw(2) E) None of these: fixed
  3. What will be displayed after the following statements execute? int num1 = 5; int num2 = 3; cout << "The result is " << (num1 * num2 + 10) << endl; A) The result is 65 B) The result is 5 * 3 + 10 C) The result is (num1 * num2 + 10) D) The result is 25 E) None of these: The result is 25
  4. The funciton pow(x, y), requires which header file? A) cstdlib B) iomanip C) iostream D) cmath E) cstring: cmath
  5. This manipulator is used to establish a field width for the value that follows it:

Unix) Exam 3 Prep

C) result = 1 D) result = 3 E) there will be no output: result = 3

  1. Input values should always be checked for A) division by zero, if division is taking place B) an appropriate range C) reasonableness D) All of these E) None of these: All of these
  2. Given the if/else statement: if (a < 5) b = 12; else d = 30; Which of the following performs the same operation? A) a >= 5? d = 30 : b = 12; B) a < 5? b = 12 : d = 30; C) d = 30? b = 12 : a = 5; D) b < 5? b = 12 : d = 30; E) None of these: a < 5? b = 12 : d = 30;
  3. What is the value of the following expression? true || false A) true B) - C) false D) + E) None of these: true
  4. What will be displayed after the following statements execute? int funny = 7, serious = 15; funny = serious % 2; if (funny != 1) { funny = 0; serious = 0; } else if (funny == 2) { funny = 10; serious = 10;

Unix) Exam 3 Prep

} else funny = 1; serious = 1; } cout << funny << " " << serious << endl; A) 10 10 B) 0 0 C) 1 1 D) 7 15 E) None of these: 1 1

  1. Given that x = 2, y = 1, z = 0, what will the following cout statement display? cout << "answer = " << (x || !y && z) << endl; A) answer = 2 B) answer = 1 C) answer = 0 E) None of these: answer = 1
  2. What is the output of the following segment of code if the value 4 is input by the user? int num; int total = 0; cout << "Enter a number from 1 to 10: "; cint >> num; switch (num) { case 1: case 2: total = 5; case 3: total = 10; case 4: total = total + 3; case 8: total = total + 6; default: total = total + 4; } cout << total << endl; A) 13 B) 0 C) 23 D) 3 E) None of these: 13

Unix) Exam 3 Prep

C) 7 D) 0: 6

  1. A special value that makes the end of a list of values is a A) variable B) sentinel C) counter D) constant E) None of these: sentinel
  2. What will the following code display? int number = 6; cout << ++number << endl; A) 6 B) 5 C) 7 D) 0: 7
  3. This operator increments the value of its operand and then uses the value in context A) postfix increment B) postfix decrement C) prefix increment D) prefix decrement E) None of these: prefix increment
  4. A for statement contains three expressions: initialization, test, and A) reversal B) validation C) update D) null E) None of these: update
  5. In the following statement, which operator is used first? while (x++ < 10) A) ++ B) < C) neither; the expression is invalid D) cannot tell without the rest of the code: <
  6. Which of the following causes a function to execute? A) a do-while loop B) a function call C) a function prototype

Unix) Exam 3 Prep

D) a for loop E) None of these: a function call

  1. functions may have the same name as long as their parameter lists are different A) Un-prototyped B) Only two C) Two or more D) No E) None of these: Two or more
  2. If a function does NOT have a prototype, default arguments may be speci- fied in the A) return type B) execution C) function header D) function call E) None of these: function header
  3. This function causes a program to terminate, regardless of which function or control mechanism is executing. A) exit() B) return() C) continue() D) terminate() E) None of these: exit()
  4. The value in this type of variable persists between function calls A) global B) internal C) dynamic D) static E) None of these: static
  5. When used as parameters, these types of variables allow a function to access the parameter's original argument: A) undeclared B) floating-pint C) counter D) reference E) None of these: reference
  6. In the following function prototype, how many parameter variables does this function have? int myFunction(double, double, double);

Unix) Exam 3 Prep

4: 4 2

  1. To access an array element, use the array name and the element's A) data type B) name C) value D) subscript E) None of these: subscript
  2. An array's size declarator must be a with a value greater than . A) number, zero B) variable, - C) constant integer expression, zero D) number, one E) None of these: constant integer expression, zero
  3. This vector function removes an item from a vector A) delete_item B) erase C) pop_back D) remove_item: pop_back
  4. Which of the following is a valid C++ array definition? A) void numbers[5]; B) int sizes[10]; C) float $payments[10]; D) int nums[0]; E) None of these: int sizes[10];
  5. A two-dimensional array can be viewed as A) rows and columns B) increments and decrements C) arguments and parameters D) All of these E) None of these: rows and columns
  6. To assign the contents of one array to another, you must use A) the equality operator with the array names B) the assignment operator with the array names C) a loop to assign the elements of one array to the other array D) Any of these E) None of these: a loop to assign the elements of one array to the other array

Unix) Exam 3 Prep

  1. What will the following code display? int numbers[] = {99, 87, 66, 55, 101}; for (int i = 1; i < 4; i++) cout << numbers[i] << " "; A) 99 87 66 55 101 B) 87 66 55 C) 87 66 55 101 D) Nothing. This code has an error.: 87 66 55
  2. To pass an array as an argument to a function, pass the of the array A) name B) value of the first element C) size, expressed as an integer D) contents E) None of these: name
  3. An array can store a group of values, but the values must be A) integers and floating-point numbers B) integers C) constants D) the same data type E) None of these: the same data type
  4. The individual values contained in an array are known as A) constants B) parts C) elements D) items E) None of these: elements
  5. When an array is sorted from highest to lowest, it is said to be in A) ascending order B) forward order C) reverse order D) descending order E) None of these: descending order
  6. The advantage of a linear search is its A) efficiency B) simplicity C) speed D) complexity E) None of these: simplicity

Unix) Exam 3 Prep temp = num2; num1 = temp; C) int temp = num1; num2 = num1; num1 = num2; D) num1 = num2; num2 = num1; E) None of these: int temp = num2; num2 = num1; num1 = temp;

  1. A(n) search uses a loop to sequentially step through an array A) binary B) relative C) linear D) unary E) None of these: linear
  2. 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 - 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 A) selection sort B) linear sort C) linear search D) binary search E) None of these: binary search

Unix) Exam 3 Prep

  1. The following is the psuedocode for which type of algorithm? For start = each array subscript, from the first to the next-to-last minIndex = start minValue = array[start] For index = start + 1 to size - 1 If array[index] < minValue minValue = array[index] minIndex = index End If End For swap array[minIndex] with array[start] End For A) bubble sort B) binary sort C) selection sort D) bubble search E) None of these: selection sort
  2. Which of the following statements if NOT valid C++ code? A) int ptr = &num1; B) float num1 = &ptr2; C) int ptr = int *num1; D) All of these are valid E) All of these are invalid: All of these are invalid
  3. To help prevent memory leaks from occurring in C++11, a auto- matically deletes a chunk of dynamically allocated memory when the memory is no longer being used A) smart pointer B) null pointer C) dereferenced pointer D) None of these: smart pointer
  4. Use the delete operator only on pointers that were A) never used B) dereferenced inappropriately C) created with the new operator D) not correctly initialized E) None of these: created with the new operator
  5. Dynamic memory allocation occurs A) when a pointer is assigned an incorrect address B) when a pointer falls to dereference the right variable

Unix) Exam 3 Prep

C) declare the pointer value again in the function call D) not dereference the pointer in the function's body E) None of these: None of these

  1. Assuming dataFile is a file stream object, the statement: dataFile.close(); A) is legal but risks losing valuable data B) closes a file C) needs a filename argument to execute correctly D) is illegal in C++ E) None of these: closes a file
  2. The function that reverses the order of a C-string is A) back B) strrev C) reverseit D) reversstr E) None of these: None of these
  3. Which of the following will return true if the argument is a printable char- acter other than a digit, letter, or a space? A) ispunct B) isprint C) ischar D) isnotdls E) None of these: ispunct
  4. What is the value stored in num after the following statement executes? num = atoi("1000"); A) "1 thousand" B) "1000" C) 1000 D) 999 E) None of these: 1000
  5. The function that converts C-string to an integer and returns the integer value is A) strint B) atoi C) atoint D) strtoint E) None of these: atoi
  6. What is the output of the following statement? cout << tolower(toupper('Z')) << endl;

Unix) Exam 3 Prep

A) uppercase z B) a compiler error C) lowercase z D) a lowercase z followed by an uppercase z E) None of these: lowercase z

  1. In C++ a C-string is a sequence of characters stored in consecutive mem- ory, terminated by a A) null character B) space C) semicolon D) period E) None of these: null character
  2. In C++11, assuming mychar is a char variable and mystring is a string, what is the value of mychar after the following statement executes? mychar = mystring.front(); A) the first character of mystring B) the ASCII value of the first character of mystring C) nothing, the function is missing an argument D) this will cause a compiler error: the first character of mystring
  3. The function concatenates the contents of one C-string with another C-string A) strcat B) strcopy C) stradd D) strappend E) None of these: strcat
  4. The null terminator stands for ASCII code A) 57 B) 100 C) 0 D) 1000 E) None of these: 0
  5. Which of the following describes only the general characteristics of an object? A) initialization B) detailed specification C) initiation