CS 159 Lab Quizzes 1-5
What is the result of the following expression: 4 / 5 / 2.0
0.0
What is the result of the following expression: (float) 4 / (float) 5
0.8
Simplify the following expression: 37 % 4
1
Simplify the following expression: 459123 % 100
23
Simplify the following expression: 459123 % 10
3
Simplify the following expression: 47 % 6
5
A local variable can be referenced through its identifier outside of the function for which it is defined.
False
A scanf statement can be used to produce output to the monitor & accept input from the user of the program.
False
A user-defined function cannot be called more than once in a given function.
False
According to course standards, it is permissible to declare more than one variable per line.
False
According to the course standards, local declarations & executable statements are permitted to overlap.
False
Functional cohesion is a measure of how may times a user-defined function is called in a program.
False
The control of the program always returns from the calling function to the main function.
False
The function call requires the data types and identifiers for each parameter.
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 result of the following expression for any non-negative integer x is 1: (x + 2) % (x + 1)
False
The result of the following expression is 17: (int) 17.3 + 0.5
False
The role of the main function is to accept input, produce output, coordinate the function calls, and to establish the data needs for a program.
False
A C program begins with a section for pre-processor directives.
True
A function may return at most one value.
True
A function that does one and only one process is functionally cohesive.
True
A printf function is composed of a format string and a data list.
True
A scanf function is composed of a format string and an address list.
True
A single-type operation will generate a result of that same type.
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
An identifier cannot begin with a digit character.
True
Comments are added to a program to improve its level of documentation intended for other programmers.
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
Given the address of a variable the called function can access and manipulate the value of that variable in the calling function.
True
In most cases the definition of symbolic/defined constants will not terminate with a semi-colon.
True
It is a course standard that all code found between { and } should be indented two additional spaces.
True
It is a good design practice to not repeat the logic of one function in other functions of the program.
True
It is course standard that you comment all variables to the right of each declaration.
True
It is course standard that you do not single (or double) space the entire program, but use blank lines when appropriate.
True
It is course standard that you place a single space between all operators and operands in your code.
True
It is possible to determine if any parameters should be passed to a function by address based on the first line of the definition of the function (also known as the function header).
True
Some operators that can be applied to a value are restricted by its data type.
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 control of the program always returns from the calling function to the function that called it.
True
The function declaration terminates with a semicolon (;).
True
The implementation of advanced concepts, those yet to be introduced in lecture, is not permitted in an assignment unless otherwise specified.
True
The return(0); statement will be the final statement in the main function.
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 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
When evaluating an operator with mixed-type operands it is the lower ranked data type that is converted to that of the higher ranked data type.
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
