CS 159 true/false labs 5-10
The number of times the update action is executed is equal to the number of times the loop control expression is evaluated in a for loop.
false
The only way to complement a NOT operator is with another NOT operator.
false
The short-circuit method of evaluating logical expressions does not apply to loop control expressions.
false
With the use of pass by address it is now permissible for a function to be written to complete several sub tasks of the program.
false
This loop iterates 6 times: (i = 1; i <= 32; i * 2)
false, 5 times.
A function that passes at least one parameter by address must pass them all by address.
fasle
A counter-controlled loop may execute a constant number of inerations.
true
A function that does one and only one process is functionally cohesive
true
A limited amount of control structures are permissible in the main function to ensure that it is the main function which makes most of the function calls for a program.
true
A nested loop is a repetitive process contained inside of another repetitive process.
true
A piece of data is called logical if it conveys the idea of true or false.
true
A structure chart may show the data that is exchanged between functions.
true
A variable declared in the local declaration section of a function has a scope that extends until the end of that function.
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 loop needs.
true
An iteration is one execution of all statements found inside the body of a loop.
true
An iterative solution involves the use of a loop to solve a repetition problem.
true
Array declarations will determine the type, name, and size of the array.
true
Arrays can be passed in two ways; by individual elements or the whole array.
true
Arrays must be declared and defined before they can be used.
true
Associated with a case label is zero or more executable statements.
true
C programmers use other types, such as integers, to represent logical data.
true
Complementing a condition is one way to potentially remove negative logic from an expression.
true
Control-forcing statements such as break, continue, exit, and the use of multiple return statements in a user-defined function are prohibited by course standards as mechanisms to terminate repetitive processes.
true
Elements of an array, themselves individual values of a given data type, are passed by value from calling to called function.
true
For a value to be potentially used as an index it must be an integral value or an expression that evaluates to such.
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
If a data value is 0 it is considered false, but any non-zero value is considered true.
true
In a fixed-length array the size of the array is known when the program is written.
true
In a post-test loop the minimum number of times that the statements found inside of the loop are executed is one.
true
In a pretest loop the control expression is evaluated before each iteration, including the first iteration.
true
In an else-if the if condition is evaluated first and additional else-if condition are evaluated until a condition is found to be true.
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
Individual elements of an array can be passed by address through the use of the address operator.
true
Input validation is an example of an event-controlled problem.
true
Is it possible to indicate on a structure chart when a user-defined is called from within a section construct.
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 many 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 poor programming style to reuse identifiers within the same scope.
true
It is possible for the number of times a counter-controlled loop will iterate to depend on the value of a single variable expression.
true
It is possible to determine if any parameters are passed to a function by address based on the first line of the definition of the function (also known as the function header).
true
It is possible to determine if any parameters are passed to a function by address from the declaration statement of the function.
true
It is possible to update/change/alter the loop control variable of a for loop inside of its body.
true
Negative logic refers to any expression that begins with a NOT operator or that contains multiple NOT operators within.
true
No code is contained in a structure chart as it only demonstrates the function flow of the program.
true
No two switch case labels can represent the same constant expression value.
true
Objects with a global scope are visible (defined) everywhere in the program.
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 pass by address is that it allows multiple changes to be made in a function and to have those changes available in the calling function.
true
Only the statements associated with the first true condition are executed in a multiway else-if construct.
true
Recursion is a repetitive process in which a function calls itself.
true
Recursion should not be used with evet-controlled processes as the result may be more function calls than the memory of the computer can accommodate.
true
Selection by itself is insufficient for input validation because it provides only a finite number of opportunities for the user to input valid data.
true
Similar to their required use in the if construct it is a course standard to always make use of { and } with all looping constructs.
true
The * and & operators are inverse operations of each other.
true
The action that is responsible for changing the result of the loop control expression from true to false is the loop update.
true
The asterisk (*) when used in a variable declaration indicates that such variables are not data variables but address (pointer) variables which can store 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 break statement results in the control of the program exiting the witch statement.
true
The called function cannot identify whether the value it receives comes from an array, an individual variable, or an expression that evaluates to the expected type.
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 case label represents an integral type value that is a possible result of the control expression.
true
The complement of the equal operator is not the equal operator.
true
The condition in a recursive function when which the recursive function calls stop is known as the base case.
true
The condition that determines whether the task to repeat is finished is known as the loop control expression.
true
The conditional expression has three operands and a two-token operator.
true
The contents of a loop have been identified to be repeated in a program.
true
The course standards limit the use of the break statement to only switch statements.
true
The do-while loop will terminate with a semicolon after its loop control expression.
true
The else does not have a condition associated with it.
true
The else is executed only when all previously evaluated conditions are false.
true
The expression if(a == 0) and if(a) are complements.
true
The expressions if(a != 0) and if(!a) are complements.
true
The first random number generated is based on a seed, either the default provided by the system or one specified by the programmer.
true
The index value represents an offset from the beginning of the array to the element being referenced.
true
The initiation of the loop control variable must take place outside of the body of a pretest loop.
true
The logical expression of an if...else construct must be enclosed in parenthesis.
true
The loop control variable is commonly a part of the loop control expression and the recipient of the loop update action.
true
The name of an array is a reference to the address of where it begins inside the memory of the computer.
true
The number of times that the loop control expression is evaluated is one more than the number of iterations in a pretest loop.
true
The random number function returns an integer between 0 and RAND_MAX, which is defined in the stdlib.h library as the largest number that rand can generate.
true
The scope of an object determines the region of the program in which it is visible (and defined).
true
The short-circuit method of evaluating logical expressions will stop evaluating the current expression as soon as the result can be determined.
true
The srand function creates the starting seed for a number series based on the value it receives.
true
The srand function must be called only once for each random number series.
true
The statements found inside of an if...else may be any statement, including another if...else construct.
true
The switch construct can only be used when the selection condition reduces to an integral expression.
true
The while loop requires the use of parentheses around the loop control expression.
true
There is no semi-colon that follows the logical expression of an if...else construct.
true
This for loop iterates 5 times: (i = 12345; i != 0; i /= 10)
true
This for lop iterates 10 times: for(i = 0; i < 10, i++)
true
To generate a random integer in a range x to y, we must first scale the number and then, if x is greater than 0, shift the number within the range.
true
To obtain the address of a variable use the address operator (&).
true
When accessing an array element the C language does not check whether the index is within the boundary of an array.
true
When attempting to print the result of a logical expression that is true as an integer the result will always be 1.
true
When only one data item needs to be returned to the calling function then we should use the standard return statement rather than passing a single parameter by address.
true
When the selection is based on a range of values, or the condition is not integral, we use the else-if for our multiway selection needs.
true
When the statements associated with one case have been executed the program flow continues with the statements for the next case.
true
When working with a parameter that has been passed by address it is unnecessary to use the & (address) operator in the scanf because the parameter already represents a memory location.
true
When writing a selection construct the most probable conditions should come before those that occur less frequently.
true
While each call to the rand function returns the next integer in the series, the srand function is a void function.
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
The complement of the greater than operator is the less that operator.
false
The dangling else logical error can be corrected by indenting the if and else the same number of spaces.
false
The following expression is used to generate a positive integer value in the range from x to y, rand() % (y - x) + x
false
The gcc complier as used in Vocareum 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 it operands is true.
false
The maximum number of actions that can be associated with a switch case label is one.
false
In order for two, or more, repetitive processes to be considered nested they must appear in the same user defined function.
false
In this course you will be expected to validate for the input of both the range of acceptable value and the correct data type.
false
It is always a logical error to associate two switch case labels with a common set of actions.
false
It is never possible to determine if any parameters are passed to a function by address from an example call to the function.
false
Iterative solutions are always better then recursive ones
false
The AND and OR operators share the same level of precedence.
false
The address operator is not necessary in a scanf to accept input for an individual array element when using the indexing technique
false
Each rectangle on a structure chart represents the user-defined and standard library functions used in a program.
false
Each switch case label is the keyword case followed by a constant expression inside of single quotes.
false
If the number of values provided for initialization of an array is fewer than the size of the array then the remaining elements have no known value.
false
In an event controlled loop we know the number of times that the actions found inside the body of the loop will be executed.
false
A reasonable effort should be made to convert most while loops into for loops.
false
A structure chart should be created after your program has been written.
false
All functions that utilize pass by address must be void functions.
false
Conditional expressions cannot be nested as the resulting code becomes more complex.
false
Declaration and definition of an array will include a default initialization of all elements.
false