engr 101 final

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What does the following command do? cal 6 2009; cal 7 2009; cal 8 2009 > summer.2009 Select one: a. Displays the calendars of June and July of 2009 on the screen and redirects the calendar of August to summer.2009 file. b. Redirects the calendar of August of 2009 to summer.2009 file and does not display anything on the screen. c. Redirects the calendar of June, July and August of 2009 to summer.2009 file. d. Displays the calendars of June, July and August of 2009 on the screen and redirects them to summer.2009 file.

Displays the calendars of June and July of 2009 on the screen and redirects the calendar of August to summer.2009 file.

Ctrl-C stops (suspends) a foreground process and Ctrl-Z interrupts (kills) a foreground process. Select one: True False

False

Main difference between the redirection and pipe: Pipe places the output of a utility into an ordinary file while redirection places the output of a utility to another utility. Select one: True False

False

The command "ls jobs" displays list of jobs. Select one: True False

False

The following command will show hidden files: ls -l. The character "~" refers to the working directory. Select one: True False

False

A process is what we get whenever the computer runs a program. Therefore, for one copy of a program, there might be many active processes. Select one: True False

True

History command shows all previous commands in a command shell. To re-run the last command we can use !! to re-run command #n in the history list: !n (where n is a number), to re-run a command starting with character 'a': !a Select one: True False

True

One file can have more than one name in Linux. This can be done using "ln" command. Select one: True False

True

Tab and Esc keys can be used to complete filenames. The exit command can be used to exit the shell. Select one: True False

True

The command "fg %n" sends job number n from background to the foreground. Select one: True False

True

The command "tee" allows doing two things at once: (1) saving the output from a command to a file, and (2) piping the output to another command. Select one: True False

True

The following are usually in /bin directory: software for the shell commands and useful software tools. "bin" is short form of binary. Select one: True False

True

There are dozens of command shells available for UNIX/Linux. The main two categories are Bourne shell and C shell families. Select one: True False

True

When a program aborts because of an error, the system produces a core dump that contains a snapshot of the main memory at the time the program failed. Most UNIX systems include special programs called debuggers to help exterminate bugs in the program. In our Linux system, we can use gdb for debugging. Select one: True False

True

Which statement is false? Select one: a. 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. b. The string termination character is called the null character. c. The character representation of the last character in memory of a string is '\0'. d. The string "string" actually occupies 7 characters in memory.

a. 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.

Which statement is true? Select one: a. The boss function is normally unaware when a worker function calls another function b. "Hiding" of implementation details makes it difficult to understand software c. A worker function may not call other worker functions. d. The boss function normally knows how the worker function performs its designated tasks.

a. The boss function is normally unaware when a worker function calls another function

Which statement is false? Select one: a. When using scanf, you must always precede with the & operator the name of each variable into which inputs are being placed. b. Function scanf can write beyond the boundary of the array into which input is being placed. c. Function scanf reads characters into memory from the keyboard until the first input whitespace character is encountered. d. Function printf does not care how large the array it is printing is.

a. When using scanf, you must always precede with the & operator the name of each variable into which inputs are being placed.

Which of the following code segments does not contain any errors? Select one: a. double triple(float n) { return (3 * n); } b. void printnum (int x) { print("%i", x); return x; } c. double circumference (int r) return (3.14 * 2 * r); d. int cube(int s) { int s; return (s * s * s); }

a. double triple(float n) { return (3 * n); }

A function prototype does not have to ________ Select one: a. include parameter names. b. terminate with a semicolon. c. match with all calls to the function. d. agree with the function definition.

a. include parameter names.

Calculating which of the following normally requires the data to be sorted first: Select one: a. median b. mode c. mean d. total

a. median

When a called function completes its task, it normally Select one: a. returns to the calling function b. terminates program execution normally c. aborts program execution d. logs its results

a. returns to the calling function

A bubble sort of 1000 elements requires a maximum of __________ passes. Select one: a. 998 b. 1001 c. 1000 d. 999

b. 1001

Which statement is false? Select one: a. Each function should be limited to performing a single, well-defined task. b. Every function should be broken into smaller functions. c. If you cannot choose a concise name that expresses what a function does, it's possible that the function is attempting to perform too many diverse tasks. d. A function's parameters are local variables.

b. Every function should be broken into smaller functions.

Which one of the following is not a method to create a file in Linux? Select one: a. Redirecting the standard output from a Linux utility b. Moving a file from other directories to working directory c. Using a text editor d. Copying an existing file

b. Moving a file from other directories to working directory

All of the following are true of functions except: Select one: a. The implementation of a function is hidden from the caller. b. The definition of a function is always visible to other functions. c. They define specific tasks that can be used at many points in a program. d. A function call must specify the name and arguments of the function.

b. The definition of a function is always visible to other functions.

Unless otherwise specified, entire arrays are passed __________ and individual array elements are passed __________. Select one: a. by-value, by-reference b. by-reference, by-value c. by-value, by-value d. by-reference, by-reference

b. by-reference, by-value

The following array definition int n[5] = {32, 27, 64, 18, 95, 14}; Select one: a. causes a syntax error because there are only five initializers and six array elements. b. causes a syntax error because there are six initializers but only five array elements. c. causes a logic error because there are only five elements but there are six initializers. d. is correct

b. causes a syntax error because there are six initializers but only five array elements.

Recursion is to the base case as iteration is to ________? Select one: a. a selection statement b. failure of the loop continuation test c. the counter d. an iteration statement

b. failure of the loop continuation test

Which statement would be used to define a 10 element integer array c? Select one: a. Array c = int[10]; b. int c[10]; c. int Array c[10]; d. c = int[10];

b. int c[10];

A function prototype can always be omitted when a function ________ Select one: a. is invoked before it is first defined. b. is defined before it is first invoked. c. takes no arguments. d. does not return a value.

b. is defined before it is first invoked.

An array is a group of memory locations related by the fact that they all have __________ array name and __________ type. Select one: a. different, different b. same, same c. same, different d. different, same

b. same, same

Assume string1 is a character array. Which of the following operations does not produce a string? Select one: a. string1[] = {'t', 'e', 's', 't', '\0'}; b. string1[] = {'t', 'e', 's', 't'}; c. string1[] = "test"; d. string1[] = " ";

b. string1[] = {'t', 'e', 's', 't'};

What is the value of fabs(-5.0)? Select one: a. -5 b. 5 c. 5.0 d. -5.0

c. 5.0

Consider the following command: chmod u+r-x myFile.txt. Which one of the following is correct? Select one: a. It adds read and removes execute permissions and does not change write permission for user's group. b. It adds read and execute permissions but it does not change write permission for user's group. c. It adds read and removes execute permissions and does not change write permission for user. d. It adds read and execute permissions but it does not change write permission for user.

c. It adds read and removes execute permissions and does not change write permission for user.

Which of the following is false about a function being passed an array? Select one: a. It is passed the address of the first element in the array. b. All of the above are true. c. It knows the size of the array it was passed. d. It is able to modify the values stored in the array.

c. It knows the size of the array it was passed.v

Which statement is true? Select one: a. A function must be no longer than one page. b. The best engineered functions have many parameters and perform many distinct tasks. c. Programs should be written as collections of small functions. d. Every function must include an explicit return statement.

c. Programs should be written as collections of small functions.

What do the following commands display on the screen (echo Today's date: 'date'); (echo Today's date: `date`) Suppose Tue Dec 1 15:04:49 EST 2015 is the time when this command is run. Note "&" is not part of the display. Select one: a. Today's date: 'date' & Today's date: Tue Dec 1 15:04:49 EST 2015 b. Today's date: Tue Dec 1 15:04:49 EST 2015 & Today's date: date c. Today's date: date & Today's date: Tue Dec 1 15:04:49 EST 2015 d. Today's date: Tue Dec 1 15:04:49 EST 2015 & Today's date: 'date'

c. Today's date: date & Today's date: Tue Dec 1 15:04:49 EST 2015

Referencing elements outside the array bounds ____________ Select one: a. is impossible because C checks to make sure it does not happen. b. enlarges the size of the array. c. can result in changes to the value of an unrelated variable. d. is a syntax error.

c. can result in changes to the value of an unrelated variable.

srand ___________ Select one: a. is unnecessary in C. b. should be called before each call to rand. c. can use time as an automatic input seed value. d. should be used instead of rand to generate truly random numbers.

c. can use time as an automatic input seed value.

The forcing of arguments to the appropriate types in function calls is commonly called __________. Select one: a. transmogrification b. conversion c. coercion d. casting

c. coercion

If there are fewer initializers than elements in the array, the remaining elements are __________. Select one: a. initialized to empty b. deleted c. initialized to zero d. ignored

c. initialized to zero

The binary search technique Select one: a. is better suited to small arrays. b. can only be used on a sorted array. c. is slower than a linear search. d. is better suited to unsorted arrays.

c. is slower than a linear search.

Recursion is memory-intensive because ________. Select one: a. it requires large data values b. it must occur numerous times before it terminates c. previous function calls are still open when the function calls it-self and the arguments of these previous calls still occupy space on the call stack d. many copies of the function code are created

c. previous function calls are still open when the function calls it-self and the arguments of these previous calls still occupy space on the call stack

When arguments are passed by __________, the caller allows the called function to modify the original variable's value. Select one: a. none of these b. both a and b c. reference d. value

c. reference

An identifier's __________ is where the identifier can be referenced in a program. Select one: a. locality b. neighborhood c. scope d. vicinity

c. scope

To pass an array to a function, specify Select one: a. the name of the array followed by a pair of brackets including the size of the array. b. the name of the array followed by a pair of brackets including a number one less than the size of the array. c. the name of the array without any brackets. d. the name of the array preceded by an empty pair of brackets.

c. the name of the array without any brackets.

The special conversion specifier for printing addresses is __________. Select one: a. %a b. %loc c. %m d. %p

d. %p

Which statement is false? Select one: a. A static local array is not created and destroyed each time the function is entered and exited. b. A static local variable exists for the duration of the program. c. Arrays that are defined static are automatically initialized once at compile time. d. A static local variable is visible to other functions.

d. A static local variable is visible to other functions.

Which statement is true? Select one: a. A symbolic constant is an identifier that is replaced with replacement text by the C preprocessor after the program is compiled. b. The #define preprocessor directive must end in a semicolon. c. Using symbolic constants to specify array sizes makes programs run faster. d. A symbolic constant is replaced with replacement text by preprocessor before the program is compiled.

d. A symbolic constant is replaced with replacement text by preprocessor before the program is compiled.

Which is not a motivation for "functionalizing" a program? Select one: a. The divide-and-conquer approach makes program development more manageable. b. Avoid repeating code. c. Software reusability—using existing building blocks to create new programs. d. Execution performance—functionalized programs run faster.

d. Execution performance—functionalized programs run faster.

Which statement is true? Select one: a. The type of every parameter in a function parameter list must be included. b. Defining a function parameter again as a local variable within the function is a logic error. c. The type of every argument in a function call must be included. d. It is not incorrect to use the same names for the arguments passed to a function and the corresponding parameters in the function definition.

d. It is not incorrect to use the same names for the arguments passed to a function and the corresponding parameters in the function definition.

Which statement is true regarding the statement ++frequency[responses[answer]]; Select one: a. This statement increases the appropriate responses counter depending on the value of frequency[answer]. b. This statement increases the appropriate answer counter depending on the value of frequency[responses]. c. This statement produces a syntax error because subscripts can-not be nested. d. This statement increases the appropriate frequency counter depending on the value of responses[answer].

d. This statement increases the appropriate frequency counter depending on the value of responses[answer].

Which statement is false? Select one: a. Labels are used in switch statements and in goto statements. b. An identifier's storage class determines the period during which that identifier exists in memory. c. Labels can be used anywhere in the function in which they appear, but can not be referenced outside the function body. d. When we define a local variable in a block it can be referenced only in that block or in blocks in which that block is nested.

d. When we define a local variable in a block it can be referenced only in that block or in blocks in which that block is nested.

Which of the following is false? Select one: a. the position number contained within square brackets is called a subscript. b. the first element of array a is the a[0]. c. the last element of the array is a[size - 1]. d. a subscript cannot be an expression.

d. a subscript cannot be an expression.

The function prototype double mySqrt(int x); Select one: a. defines a function called mySqrt which takes a double as an argument and returns an integer. b. defines a function called mySqrt which takes an argument of type x and returns a double. c. defines a function called double which calculates square roots. d. defines a function called mySqrt which takes an integer as an argument and returns a double.

d. defines a function called mySqrt which takes an integer as an argument and returns a double.

All of the following are reasons to use recursion except: Select one: a. it more naturally mirrors the problem. b. an iterative solution is not apparent. c. the resulting program is easier to debug. d. it maximizes software performance.

d. it maximizes software performance.

To prevent modification of array values in a function Select one: a. the array must be defined static in the function. b. the array must be passed by-reference. c. a copy of the array must be made inside the function. d. the array parameter can be preceded by the const qualifier.

d. the array parameter can be preceded by the const qualifier.


Ensembles d'études connexes

FIN 401-chapter 19 Multiple Choice

View Set

Lesson 5: Public Restrictions on Land: Pop Quiz

View Set

TM Test 2, Talent Management Exam 2

View Set

AP Macro Chapter 12 Multiple Choice

View Set

Chapter 12: The President: American Government

View Set

ATI - Adult Medical Surgical NGN B

View Set

EAPS 10500 | Units 10-12 (Moons, Tides, and Rings; Exoplanets; Hazards of Space Travel) | Study Guide (Exam 4)

View Set

RIZAL: RA 1425 & IMPORTANCE OF RIZAL SUBJECT

View Set