CS 159 True/False

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

If more than one element of an array is passed to a function in a single function call then each of those individual elements must be passed by address.

False

In additional to alphabetic and digits characters it is acceptable to use underscores, dashes, and periods as part of an identifier.

False

In this course you will be expected to validate for the input of both the range of acceptable values and the correct data type.

False

It is a logical error to associate two switch case labels with a common set of actions.

False

Iterative solutions are always better than recursive ones.

False

Once the insertion sort places a value in the sorted list that value will never move again in the remainder of the passes.

False

Parameters being received by a function will be commented to the right of where they are defined.

False

The C language uses only pass by value and return to achieve communication of data between a calling and a called function.

False

The actions found inside the body of a pretest loop will be executed at least one time.

False

The binary searching algorithm should always be used for searching.

False

The binary searching algorithm will always find a target in an array faster than the linear searching algorithm.

False

The bubble sorting algorithm is optimized to stop the process when the array is detected as being sorted.

False

The complement of x > 0 && x < 10 || x % 2 == 0 is x <= 0 || x >= 10 && x % 2 != 0

False

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

False

The first line of the function definition terminates with a semicolon (;).

False

The function call requires the data types and identifiers for each parameter.

False

The function declaration requires the data types and identifiers for each parameter.

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. See pages 318-319.

False

The linear and binary searching algorithms perform in the same amount of time that a given value is not present in an array.

False

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

False

The only way to stop a program caught in an infinite loop is to shut down your terminal software.

False

The parentheses around the logical expression of an if statement are optional.

False

The precision modifier can specify the number of digits to display on both sides of the decimal-point with a floating-point value.

False

The return statement cannot contain an expression.

False

The return statement in main will return control back to the first statement in main.

False

The selection sorting algorithm can only be used to sort data in an ascending order (from smallest to largest).

False

The short-circuit method of evaluating logical expressions does not apply to loop control expressions.

False

The size of the array must appear in the function declaration and function definition of a user-defined function that has a whole array as a parameter.

False

The update expression of a for loop may only make use of the addition or subtraction operator (includes ++, --, +=, -=, +, -).

False

This for loop will iterate 6 times: for(i = 1; i <= 32; i * 2)

False

To pass the whole array to a function you need to use the name of the array along with its size in the function call.

False

To pass the whole array to a function you need to use the name of the array followed by empty square braces [] in the function call.

False

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

False

When a whole array is passed to a function, C passes (a copy of) the value for each element.

False

When an array is partially initialized, the remainder of the elements are garbage (unknown) values.

False

When passing a whole array to a function the function call must contain the name followed by empty square braces.

False

You should declare multiple variables on one line.

False

A variable declared in the local declaration section of a function has a scope that extends until the end of that function.

True

A variable that is not initialized at the time it is declared will be storing an unknown value.

True

A width modifier is used to reserve a given number of spaces to assist with the alignment of the value being displayed.

True

According to the course standards a for loop should only be used with counter-controlled processes.

True

According to the course standards if all three expressions are not needed in a for loop then you should instead make use of a while loop for your pretest looping needs.

True

Additional local variables can be defined in the local declaration section of a function.

True

All code found between { and } should be indented two additional spaces.

True

All variables should be commented to the right of each declaration.

True

An identifier cannot begin with a digit character

True

An infinite loop is a logical error.

True

An integer variable or expression may potentially be used as an index to reference an element of an array.

True

An iterative solution is one that is implemented using a looping construct.

True

Any compiler warnings remaining in a submission will result in a loss of points.

True

Control-forcing statements such as break, continue, and the use of multiple return statements in a user-defined function are prohibited by course standards as mechanisms to terminate repetitive processes.

True

Course standards prohibit the use of break to terminate any repetition construct.

True

Data sent from the calling function to the function being called will be received in the same order in which it was passed.

True

Do not single (or double) space the entire program, use blank lines when appropriate.

True

Each rectangle on a structure chart represents the user-defined and standard library functions used in a program.

True

Every program must have exactly one function named main.

True

Functional cohesion is a measure of how closely the processes in a function are related.

True

Given the address of a variable the called function can access and manipulate the value of a variable in the calling function.

True

In downward communication (passing by value) it is only a copy of the data that is sent from the calling function to the called function.

True

In most cases the definition of symbolic/defined constants will not terminate with a semi-colon.

True

Individual tasks in a program must be factored into individual user-defined functions.

True

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

True

It is a course standard to make use of a symbolic/defined constant to represent the size of a statically declared array.

True

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

True

It is a good design practice to limit user-defined functions to only a single task.

True

It is a good design practice to not repeat the logic of one function in other functions of the program.

True

It is expected for most cases that the code for the validation of input be found in the same function that contains the prompt for input and scanf statement.

True

It is not possible to access a variable in the calling function by its identifier when inside the called function.

True

It is not possible to send the whole array to a user-defined function by value.

True

It is poor programming style to reuse identifiers within the same scope.

True

Multi-line comments cannot be nested.

True

No code is contained in a structure chart and only demonstrates the function flow through the program.

True

No two switch case labels can represent the same constant expression value.

True

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

True

On the final pass through the selection sorting algorithm TWO values are brought over from the unsorted list into the sorted list.

True

Once the bubble sort places a value in the sorted list that value will never move again in the remainder of the passes.

True

One approach to potentially make solving problems that require nested loops easier is to separate each repetitive process into its own function.

True

One benefit of user-defined functions is the potential reduction or elimination of duplicate code.

True

Parameters are defined as local variables in the function header and should not be re-defined within the local declaration section of the function.

True

Recursion should not be used with event-controlled processes as the result may be more function calls than the memory of the computer can handle.

True

Recursive solutions may involve heavy use of the limited resources of the computer because they involve a potentially large number of function calls.

True

Select meaningful identifiers (names) for all variables in your program.

True

Selection alone is not used with input validation because it provides only a finite number of opportunities for the user to input valid data

True

The asterisk (*) in a variable declaration indicates that the variables are not data variables but address variables holding the addresses of other variables in the program.

True

The asterisk has two different uses, declaring an address variable (pointer) and indirectly accessing the data (in the memory location to which the variable points).

True

The binary searching algorithm will terminate when the first variable is greater than the last.

True

The bubble sorting algorithm compares neighboring elements in the unsorted list of the array and swaps their positions when they are not in the desired order.

True

The compiler will issue a warning when an assignment operator rather than the equality operator is used in the logical expression of an if condition.

True

The complement of x % 3 == 0 || x % 3 == 2 is x % 3 != 0 && x % 3 != 2

True

The complement of x > 3 is x <= 3

True

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

True

The conditional expression has three operands and two operators.

True

The control expression that follows the keyword switch may be an integer or character expression.

True

The conversion code to use for input or output of an array element depends on the data type of the array.

True

The data type of a variable will determine the amount of memory that is necessary to reserve for it.

True

The data type of all elements in an array must be the same.

True

The files stdio.h and math.h are libraries that contain standard functions for our use

True

The following two logical expressions are equivalent: !(x < 10) and x >= 10

True

The following two logical expressions are equivalent: x % 2 and x % 2 != 0

True

The function call is an executable statement.

True

The function definition contains executable statements that perform the task of the function.

True

The function definition requires the data types and identifiers for each parameter.

True

The implementation of advanced concepts, those yet to be introduced in lecture, is not permitted in an assignment.

True

The individual task represented by a function should be testable apart from the rest of the program.

True

The initialization of the loop control variable should take place outside (before) a pretest loop.

True

The insertion sorting algorithm begins with one value in the sorted list before the first pass.

True

The loop control variable is often a part of the loop control expression and the recipient of the actions of the loop update.

True

The memory address represented by the name of an array is added to the index value specified to determine where in memory the desired element can be found.

True

The name of an array represents a memory address.

True

The operators that can be applied to a value are restricted by its data type.

True

The responsibility to check an index value against the acceptable range of index values is left to the programmer.

True

The return(0); statement is usually the final statement in the main function

True

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

True

The scope of an object determines the region of the program in which it is visible.

True

The selection of a conversion code in a format string depends on the type of value it will represent.

True

The selection sorting algorithm will complete one exchange involving at most two elements per pass.

True

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

True

The size of a statically declared array cannot change during the execution of the program.

True

The size of a statically declared array is determined prior to the compiling of the program.

True

The update to the loop control variable is responsible for terminating the loop because it will eventually result in the loop control expression in being false.

True

The use of literal constants should be minimized and the use of symbolic/defined constants should be maximized in your program.

True

The use of symbolic/defined constants can improve the documentation of a program.

True

The value of a local variable may be returned through a return statement of a user-defined function.

True

There is no need to include example output with your submission.

True

This for loop will iterate 10 times: for(i = 0; i < 10; i++)

True

This for loop will iterate 5 times: for(i = 12345; i != 0; i /= 10)

True

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

True

To sort an array of SIZE elements, a total of SIZE - 1 passes are required to guarantee that the data is sorted using the selection, bubble, or insertion sort.

True

To store a memory address that is sent from the calling function, the called function should use a special type of variable known as a pointer.

True

Variable declarations will NEVER be permitted in the global section this semester.

True

Variables and loops are commonly used together to generate index values to access the elements of an array.

True

When an array is not sorted and the data in the array is NOT unique the linear searching algorithm requires every element to be compared with the target before the number of occurrences of the target can be accurately calculated.

True

When an array is not sorted and the data in the array is unique, the linear searching algorithm requires every element to be compared with the target before it can be concluded that the target is not present in the array.

True

When an element of an array is passed to a function, C passes (a copy of) the value of that element.

True

When only one data item needs to be returned we should use the standard return statement.

True

While commonly used in a printf function the scanf function would not make use of the '\n' character.

True

While the default technique of passing array elements is by value it is possible to pass elements by address using the & operator (and the * operator in the function being called).

True

Within each function the local declarations and executable statements must NOT be permitted to overlap.

True

You can make use of x++, ++x, x += 1, and x = x + 1 interchangeably as the update (third) expression of a for loop to increment the loop control variable.

True

You should place a single space between all operators and operands.

True

Arrays in the C programming language use an index starting with 1.

False

A function may return at most one value.

True

A function that does one and only one process is functionally cohesive.

True

A large number of recursive function calls may result in a crash due to running out of memory.

True

A limited amount of repetition structures are permissible in the main function if it is appropriate to control the main program processes.

True

A literal constant is data that is not represented by any other symbol in a given expression.

True

A local variable cannot be referenced through its identifier outside of the function for which it is defined.

True

A nested loop is a repetitive process contained inside of another repetitive process.

True

A printf function is composed of a format string and a data list.

True

A program that does not compile cannot be successfully submitted for grading.

True

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

True

A user-defined function may be called more than once in a program.

True

Attempting to access an index found outside the defined index range will always result in a crash.

False

Course standards require brackets { and } to be used with all if-else constructs.

False

Each switch case label is the keyword case which must be followed by a constant expression inside of single quotes.

False

3 == 4 || 6 || 8

True

3 || - 3 || 10 || - 10

True

3 || 6 && 0

True

6 % 2 || 7 % 2

True

A C program usually begins with a section for pre-processor directives.

True

A dangling else logical error can be avoided through the use of { and } with all nested if/else constructs.

True

A function header comment for every user-defined function must be inserted immediately above the definition of the function it is documenting.

True

A scanf function is composed of a format string and a data list.

False

A single scanf function call can be used to display the prompt for input to the user and accept the input from the user.

False

A structure chart should be created after your program has been written.

False

A terminal semicolon after an if condition is optional.

False

A user-defined function that accepts a whole array as a parameter is restricted to accept only arrays of a given SIZE as defined by the programmer.

False

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

False

All elements of one array can be assigned to another through the use of the assignment operator and the name of each array (example: x = y).

False

All while loops can be converted into for loops that abide by course standards.

False

3 && - 3 && 10 && - 10

True

3 == 3 && - 1 && 1

True

A file handle used to read external data into a program should always be compared with an error value to determine the data file was opened as expected before allowing the program to continue.

na

A loop that uses the result of the feof function as a control expression will iterate the same number of times as there are items in the data file to read (assume one scalar value per iteration is read).

na

In Octave/MATLAB the fclose function can only be used to a close a connection that has been successfully opened.

na

The feof function will return a zero when the end of the file has been reached.

na

The file extension (.dat, .txt) in the name of the external file being accessed does not have to be referenced in the fopen function call.

na

The fscanf function references the name of the file handle but NOT the name of the external file (as one of its parameters).

na

The name of the external file being accessed is case insensitive when referenced in the fopen function call.

na

The name of the external file is the parameter to the fclose function.

na

The parameter to the feof function is a file handle.

na

The value returned from the fopen function is used to initialize a file handle.

na

The value returned from the fscanf function is the data value that was read from the external file.

na

When the file handle stores a file ID value equal to zero it means the external file failed to open as expected.

na


Set pelajaran terkait

Jarvis Ch. 27: Female Genitourinary

View Set

Chapter 1: Human Resource Management: Gaining a Competitive Advantage

View Set

Chapter 34: Child Health Assessment

View Set

Sociology First Test Sample test

View Set

A&P Ch 4 Skin and Body Membranes

View Set

2 - Life/Health Insurance Underwriting

View Set