Accounting
Anthropology
Archaeology
Art History
Banking
Biology & Life Science
Business
Business Communication
Business Development
Business Ethics
Business Law
Chemistry
Communication
Computer Science
Counseling
Criminal Law
Curriculum & Instruction
Design
Earth Science
Economic
Education
Engineering
Finance
History & Theory
Humanities
Human Resource
International Business
Investments & Securities
Journalism
Law
Management
Marketing
Medicine
Medicine & Health Science
Nursing
Philosophy
Physic
Psychology
Real Estate
Science
Social Science
Sociology
Special Education
Speech
Visual Arts
Computer Science
Q:
Labels are the only identifiers with
(a) function scope
(b) file scope
(c) block scope
(d) function-prototype scope
Q:
Global variables and function names are of storage class __________ by default.
a) register
b) extern
c) static
d) auto
Q:
An identifier's __________ is where the identifier can be referenced in a program.
a) locality
b) vicinity
c) neighborhood
d) scope
Q:
Which is not an attribute of a variable?
a) storage class
b) storage duration
c) scope
d) external class
Q:
Which is not a storage class?
a) automatic
b) register
c) extern
d) static
Q:
Which is not an attribute of a variable?
a) name
b) definition
c) type
d) value
Q:
Which of the following is not true of static local variables?
(a) They"re accessible outside of the function in which they are defined.
(b) They retain their values when the function is exited.
(c) They"re initialized to zero if not explicitly initialized by the programmer.
(d) They can be pointers.
Q:
An identifier's storage class
(a) determines the period during which that identifier exists in memory
(b) determines whether an identifier in a multiple-source-file program is known only in the current source file or in any source file with proper definitions
(c) determines where the identifier can be referenced in a program
(d) all of the above
Q:
Which statement is false?
a) Function rand generates an integer between 0 and MAX.
b) The range of values produced directly by rand is often different than what is needed in a specific application.
c) The number 6 in the expression rand % 6 is called a scaling factor.
d) The rand function prototype is in <stdlib.h>.
Q:
srand
(a) should be called before each call to rand
(b) should be used instead of rand to generate truly random numbers
(c) is unnecessary in C
(d) can use timeas an automatically input seed value
Q:
In the expression
n = a + rand() % b;
(a) b is the shifting value
(b) a is the scaling value
(c) b is equal to the width of the desired range of integers
(d) both (a) and (c)
Q:
A variable that can have values only in the range 0 to 65535 is a
(a) four-byte int
(b) four-byte unsigned int
(c) two-byte int
(d) two-byte unsigned int
Q:
The randfunction generates a data value of the type
(a) unsigned int
(b) int
(c) long int
(d) short int
Q:
Which statement is true?
a) When an argument is passed call by reference, a copy of the argument's value is made and passed to the called function.
b) With call by reference, changes to the passed value do not affect the original variable's value in the calling functions.
c) Call by value should be used whenever the called function does not need to modify the value of the caller's original value.
d) Call by value should only be used with trusted called functions that need to modify the original variable.
Q:
When arguments are passed by __________, the caller allows the called function to modify the original variable's value.
(a) value
(b) reference
(c) both a and b
(d) none of these
Q:
Which standard library header file contains function prototypes for conversions of numbers to text and text to numbers, memory allocation, random numbers and other utility functions.
a) <stdarg.h>
b) <stdlib.h>
c) <stdutl.h>
d) <stddef.h>
Q:
Each standard library has a corresponding __________.
(a) function
(b) variable type
(c) header file
(d) cd-rom
Q:
The forcing of arguments to the appropriate types is commonly called __________.
a) conversion
b) casting
c) coercion
d) transmogrification
Q:
Which statement is false?
a) The compiler uses function prototypes to validate function calls.
b) Prior to ANSI C, C did not include function prototypes.
c) A function prototype tells the compiler the type of data returned by the function, the number of parameters the function expects to receive, the types of these parameters and the order in which parameters of these types are expected.
d) The designers of ANSI C++ borrowed the notion of function prototypes from the developers of C.
Q:
A function prototype can always be omitted when a function ________.
(a) is defined before it is first invoked
(b) is invoked before it is first defined
(c) takes no arguments
(d) does not return a value
Q:
A function prototype does not have to ________.
(a) include parameter names
(b) terminate with a semicolon
(c) agree with the function definition
(d) match with all calls to the function
Q:
Which statement is true?
a) Programs should be written as collections of small functions.
b) A function must be no longer than one page.
c) The best engineered functions have many parameters and perform many distinct tasks.
d) Every function must include an explicit return statement.
Q:
Which statement is false?
a) Every block is a compound statement.
b) Every compound statement is a block.
c) Blocks can be nested.
d) Compound statements can be nested.
Q:
Which statement is true?
a) The type of every parameter in a function parameter list must be included.
b) The type of every argument in a function call must be included.
c) 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) Defining a function parameter again as a local variable within the function is a logic error.
Q:
Placing a semicolon after the right parenthesis enclosing the parameter list of a function definition is a __________ error.
a) logic
b) syntax
c) fatal runtime
d) nonfatal runtime
Q:
The most concise notation to use to define function parameters x and y as double is __________.
a) x, y
b) x, double y
c) double x, y
d) double x, double y
Q:
The type of a parameter whose type is omitted in a function definition is __________.
a) int
b) double
c) long
d) float
Q:
As used in
int square(int);
int is not a(n) __________.
a) data type
b) parameter type
c) return type
d) function prototype
Q:
int square(int); is an example of a function __________.
a) datatype
b) stereotype
c) prototype
d) proceduretype
Q:
Which of the following code segments does not contain any errors?
(a)
void printnum (int x)
{
print("%i", x);
return x;
}
(b)
int cube(int s)
{
int s;
return (s * s * s);
}
(c)
double triple(float n) {
return (3 * n);
}
(d)
double circumference (int r)
return (3.14 * 2 * r);
Q:
Which of the following is not an indication that a function may be too complex?
(a) it has a large size
(b) it has a large parameter list
(c) its name is a clear reflection of its function
(d) it performs multiple tasks
Q:
Which of the following will not produce a syntax error?
(a) Omitting a return type from a function definition if the function prototype specifies a return type other than int
(b) Returning a value from a function defined as void
(c) Defining a function parameter again inside a function
(d) Using the same names for arguments passed to a function and the corresponding parameters in the function definition
Q:
The function prototype
double mySqrt(int x);
(a) defines a function called mySqrt which takes an integer as an argument and returns a double
(b) defines a function called double which calculates square roots
(c) defines a function called mySqrt which takes an argument of type x and returns a double
(d) defines a function called mySqrt which takes a double as an argument and returns an integer
Q:
Which statement is false?
a) Each function should be limited to performing a single, well-defined task.
b) 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.
c) Every function should be broken into smaller functions.
d) A function's parameters are local variables.
Q:
Which is not a motivation for "functionalizing" a program?
a) The divide-and-conquer approach makes program development more manageable.
b) Software reusabilityusing existing building blocks to create new programs.
c) Avoid repeating code.
d) Execution performancefunctionalized programs run faster.
Q:
A valid reason for building programs out of functions is
(a) that the divide-and-conquer approach facilitates program construction
(b) that pre-existing functions can be used to create new programs
(c) the avoidance of code iteration within a program
(d) all of the above
Q:
Which of the following is not included in <math.h>?
(a) pow
(b) floor
(c) ln
(d) log10
Q:
What is the value of fabs(-5.)?a) 5b) 5.c) -5d) -5.
Q:
If a = 7.0, b = 7.0 and c = 6.0, then what is printed by
printf("%.2f", sqrt(a + b * c));
a) 49
b) 7.00
c) 7
d) 49.00
Q:
All functions in the math library return the data type __________.
a) float
b) int
c) long
d) double
Q:
Functions are __________ by a function call.
a) inveigled
b) invoked
c) internalized
d) inverted
Q:
Which statement is true?
a) The boss function normally knows how the worker function performs its designated tasks.
b) A worker function may not call other worker functions.
c) "Hiding" of implementation details makes it difficult to understand software.
d) The boss function is normally unaware when a worker function calls another function.
Q:
When a called function completes its task, it normally
a) terminates program execution normally
b) aborts program execution
c) logs its results
d) returns to the calling function
Q:
Which one item is most different from the other three?
a) worker function
b) caller
c) calling function
d) boss function
Q:
Which is not an ANSI standard library function?
a) printf
b) main
c) scanf
d) pow
Q:
Experience has shown that the best way to construct a program is from small pieces. This is called __________.
a) bottom up
b) the whole is greater than the sum of the parts
c) divide and conquer
d) recursion
Q:
All of the following are true of functions except:
(a) they define specific tasks that can be used at many points in a program
(b) a function call must specify the name and arguments of the function
(c) the definition of a function is always visible to other functions
(d) the implementation of a function is hidden from the caller
Q:
Which of the following statements is true?
(a) The C standard library does not provide a secure random-number generator.
(b) According to the C standard document's description of function rand, "There are no guarantees as to the quality of the random sequence produced and some implementations are known to produce sequences with distressingly non-random low-order bits."
(c) The CERT guideline MSC30-C indicates that implementation-specific random-number generation functions must be used to ensure that the random numbers produced are not predictable
(d)All of the above.
Q:
Which statement is false?
a) Both recursion and iteration are based on a control statement.
b) Both iteration and recursion involve iteration.
c) Iteration with sentinel-controlled iteration and recursion each gradually approach termination.
d) Both iteration and recursion can occur infinitely.
Q:
Which of the following statements is true?
(a) If the return value of function scanf matches the number of items that should have been input, then all the inputs are valid.
(b) Even if a scanf operates successfully, the values read might still be invalid.
(c) When a program expects to receive input values in a specific range, you should peform range checking on the inputs to ensure that the values received are indeed in that range (e.g., in a program that expects grades in the range 0-100, you should check that every grade is in that range).
(d)Both (b) and (c).
Q:
Which of the following statements is true?
(a) Function scanf does not return a value.
(b) You should never check the return value of function scanf.
(c) You should check the return value of function scanf to ensure that the value it returns matches the number of items that should have been input.
(d)None of the above.
Q:
Which statement is true?
a) Connecting flowchart symbols arbitrarily always forms structured programs.
b) In a structured program, control statements can only be stacked or sequenced.
c) In the "Rules for Forming Structured Programs (and Structured Flowcharts)," the rule that states, "Any rectangle (action) can be replaced by any control statement" is called the "nesting rule."
d) Structured programming does not improve the program-development process.
Q:
The ____________, __________, and ____________ are the only three forms of control necessary.
(a) switch, if, else
(b) sequence, selection, iteration
(c) break, continue, ifelse
(d) for, while, dowhile
Q:
Which statement is false?
a) Any expression in C that produces a value can be used in the decision portion of any control statement.
b) When tested for truth or falsity, an expression that produces a nonzero value is treated as true.
c) Assignments in C produce a value, namely the value that the left-hand side of the assignment had prior to the assignment.
d) Operator == is for comparisons; operator = is for assignment.
Q:
Of the following, which is not a logic error?
(a) Using the assignment (=) operator instead of the (==) equality operator to determine if two values are equal
(b) Dividing by zero
(c) Failing to initialize counter and total variables before the body of a loop
(d) Using commas instead of the two required semicolons in a for header
Q:
Consider the following code, assuming that x is an integer variable with an initial value of 12:
if (x = 6) {
printf("%i", x);
}
What is the output?
(a) 6
(b) 12
(c) nothing
(d) a syntax error is produced
Q:
Non-constant variables are also known as
(a) lvalues, but can be used as rvalues
(b) lvalues, and can not be used as rvalues
(c) rvalues, but can be used as lvalues
(d) constant variables
Q:
Which statement is true?
a) Operator || has a higher precedence than operator &&.
b) In expressions involving operator ||, making the condition that is most likely to be false the leftmost condition can often reduce execution time.
c) The logical negation operator is a binary operator.
d) In expressions using operator &&, making the condition that is most likely to be false the leftmost condition can often reduce execution time.
Q:
Which statement is true?
a) To test multiple conditions in the process of making a decision requires logical operators.
b) The keywords for the logical operators are AND, OR and NOT.
c) The logical AND of two expressions is true if and only if each of the conditions is true.
d) Truth tables deal only with cases in which all conditions are truthful (i.e., true).
Q:
An example of a unary operator is
(a) a relational operator
(b) an assignment operator
(c) an increment operator
(d) a logical operator
Q:
An operator that associates from right to left is
(a) !=
(b) ,
(c) ()
(d) ?:
Q:
The condition
num != 65
cannot be replaced by:
(a) num > 65 || num < 65
(b) !(num == 65)
(c) num " 65
(d) !(num " 65)
Q:
The OR (||) operator
(a) has higher precedence than the AND (&&) operator
(b) stops evaluation upon finding one condition to be true
(c) associates from right to left
(d) is a ternary operator
Q:
In C, the condition 4 > y > 1
(a) evaluates correctly
(b) does not evaluate correctly and should be replaced by (4 > y && y > 1)
(c) does not evaluate correctly and should be replaced by (4 > y & y > 1)
(d) does not evaluate correctly and should be replaced by (4 > y || y > 1)
Q:
Which statement is true?
a) The break statement causes an immediate exit from a while, for, do while or if else statement.
b) The continue statement is designed for use with the while, for, do while or switch statements.
c) An equivalent while statement for any for statement can always be formed.
d) The break statement causes an immediate exit from a while, for, do while or switch statement.
Q:
Which of the following is false?
(a) break and continue statements alter the flow of control.
(b) continue statements skip the remaining statements in the body of the loop in which they are embedded.
(c) break statements exit from the loop in which they are embedded.
(d) a continue statement can never appear in the else part of an if statement.
Q:
Which statement is true?
a) The do while iteration statement is an alternate notation for the while iteration statement; these statements function identically.
b) The do while iteration statement tests the loop-continuation condition before the loop body is performed.
c) The loop body of a correct do while iteration statement is always executed at least once.
d) The braces delineating the body of a do while statement are always required.
Q:
The program segment
int counter = 1;
do {
printf("%i ", counter);
} while (++counter <= 10);
will ________.
(a) print the numbers 1 through 11
(b) print the numbers 1 through 10
(c) print the numbers 1 through 9
(d) cause a syntax error
Q:
If a dowhile statement is used,
(a) an infinite loop will not take place
(b) the counter must be preincremented if it's also the condition
(c) the body of the loop will execute at least once
(d) an off-by-one error will not occur
Q:
Which statement is true?
a) EOF must have the value 1 on all C systems.
b) EOF is a symbolic constant defined in the <symbol.h> header file.
c) EOF is a symbolic variable defined in the <stdio.h> header file.
d) EOF is a symbolic integer constant defined in the <stdio.h> header file.
Q:
Which statement regarding the switch statement is false?
a) It's appropriate for algorithms that contain a series of decisions in which a variable or expression is tested separately for each of the constant integral values it may assume.
b) The default case is required.
c) The default case must be at the bottom of the switch after all the non-default cases.
d) Many cases may all invoke the same code.
Q:
In a switch statement
(a) a breakis required after each case
(b) multiple actions do not need to be enclosed in braces
(c) a defaultcaseis required
(d) a breakis required after the defaultcase
Q:
A switch statement should be used
(a) as a single-selection statement
(b) as a double-selection statement
(c) when a variable may assume many different values which must be tested
(d) to replace all if and ifelse statements
Q:
Which statement is true?
a) The conversion specifier %7.2f prints a floating-point value with a field width of 10 positions.
b) The conversion specifier %7.2f prints a floating-point value with 7 positions to the left of the decimal point.
c) The conversion specifier %7.2f prints a floating-point value with 5 positions to the left of the decimal point.
d) The conversion specifier %7.2f prints a floating-point value with 4 positions to the left of the decimal point.
Q:
Which statement is true?
a) Use float variables to perform monetary calculations in C.
b) Use double variables to perform monetary calculations C.
c) Monetary calculations can be performed in C.
d) Printing with %.2f guarantees correct monetary calculations in C.
Q:
Which expression raises x to the y power?
a) x ** y
b) x ^ y
c) x pow y
d) pow(x, y)
Q:
Which statement is generally false?
a) Statements preceding a for and statements in the body of a for should typically be merged into the for header.
b) Limit the size of control statement headers to a single line, if possible.
c) Initialization of a for loop control variable can occur before the for loop executes and not in the loop itself.
d) The increment portion of a for header can be a decrement.
Q:
What is produced by a for statement with a correct body and with the following header
for (i = 20; i >= 2; i += 2)
a) a syntax error
b) a divide-by-zero error
c) an infinite loop
d) the even values of i from 20 down to 2.
Q:
What is the highest value assumed by the loop counter in a correct for statement with the following header?
for (i = 7; i <= 72; i += 7)
a) 7
b) 77
c) 70
d) 72
Q:
The for statement header
for (i = 1; i < 100; ++i)
performs the body of the loop for
a) values of the control variable from 1 to 100 in increments of 1.
b) values of the control variable from 1 to 99 in increments of 1.
c) values of the control variable from 0 to 100 in increments of 1.
d) values of the control variable from 0 to 99 in increments of 1.