|
|
CS 215: UNIX C Programming
Review for Quiz 4
- A function is a self-contained unit of program
code design to _____.
- replace main()
- trap all input errors
- accomplish a particular task
- avoid I/O files
- Functions do all of the following EXCEPT
- Make a program easier to read.
- Make a program more modular.
- Make a program easier to repair.
- Make a program bug free.
- Which of the following best explains the statement
void starbar(void)
- function prototype
- function definition
- function call
- function declaration
- What is another way of writing the following statements?
if (n < m)
return (n);
else
return (m);
- return (n < m) ? n : m;
- (n < m) return ? n : m;
- return (n < m) ? return (n) : return (m);
- return (n < m) ? return (n : m);
- A function with no return value should be declared
as type ___.
- void
- int
- null
- float
- A function ___ informs the compiler which type the function
is, but the function ___ supplies the actual code.
- definition, call
- declaration, definition
- definition, declaration
- call, declaration
- When a function calls itself, it is termed ___.
- recession
- recessing
- receiving
- recursion
- What is the maximum number of times a function can
call itself?
- zero
- once
- twice
- There is no upper limit.
- With a recursive call, each call is balanced with a ___.
- prototype
- return
- argument
- EOF
- Although each level of recursion has its own ____,
the ___ itself is not duplicated.
- parameters, recursive call
- argument list, function
- set of variables, code
- prototype, function call
- Binary notation represents numbers in terms of powers of ___
- 0 or 1
- 2
- 10
- Both a and b are correct.
- In which directory would the following include file be found?
#include "hotels.h"
- system library directory
- current working directory
- system .h directory
- main .h directory
- A pointer is a variable used to store a(n) ____.
- operand
- operator
- variable
- address
- Which of the following statements will display the
address of the variable pooh, where
pooh = 24;
- printf(" %d", &pooh);
- printf(" %d", *pooh);
- printf(" %p", &pooh);
- printf(" %p", *pooh);
- In C, each function uses ___ variables.
- it's own
- shared
- duplicate sets of
- common
- Which of the following completes the swap of the
variables x and y, given the statements
temp = x;
x = y;
- y = x;
- y = temp;
- x = temp;
- temp = y;
- ___ is a pointer variable and ___ may be a regular
variable, given the statement
ptr = &pooh;
- ptr, pooh
- pooh, ptr
- Both a and b are correct.
- None of the above are correct.
- Which of the following statements finds the value
(val) that ptr, a pointer variable, points to?
- val = & ptr;
- val = * ptr;
- ptr = & val;
- ptr = * val;
- Which of the following declares pi as a pointer to int?
- int pi;
- int * (&pi);
- int & pi;
- int * pi;
- Which of the following passes the address of
x and y to the function change_them()?
- change_them( &x, &y);
- change_them( x, y);
- change_them( *x, *y);
- change_them( &(*x), &(*y));
- Given the following function call, which of the
following function headings is correct?
change_it (&x, &y);
- void change_it (int x, int y)
- void change_it (int &x, int &y)
- void change_it (int *x, int *y)
- void change_it (*int x, *int y)
- What are the values 5 and 2, given that they
are assigned to a and b, respectively, in the statement
c = diff(a, b);
- formal arguments
- informal arguments
- actual arguments
- pointer arguments
- Functions must have the same ___ as the value they return.
- value
- type
- address
- argument
- An array is composed of a series of ___ of one data type.
- elements
- articles
- subscripts
- events
- All of the following are C storage classes except which one?
- external
- public
- static
- automatic
- Which one of the following storage classes is used to
define a variable or array outside a function?
- external
- public
- private
- automatic
- Which one of the following would be used to
initialize an array?
- int shows[5] = [12, 10, 8, 9, 6];
- int shows[5] = [12, 10, 8, 9, 6, ];
- int shows[5] = {12, 10, 8, 9, 6 };
- int shows[5] = {12, 10, 8, 9, 6, };
- Which one of the following storage classes is placed inside
a function, but retains its value(s) between function calls?
- external
- public
- static
- automatic
- Which keyword serves to remind the programmer that an
array is defined elsewhere in the program as an external?
- ext
- extern
- external
- ex
- If you do not initialize an automatic array,
all array elements are set to _________.
- NULL
- 0
- 1
- Garbage values
- When empty ____ are used to initialize an array,
the compiler will count the number of items in the
list and make the array that large.
- brackets []
- braces {}
- parentheses ()
- pipes ||
- Adding 1 to a pointer increases its value by the size,
in ___ of the pointed to object.
- words
- bits
- bytes
- units
- Which of the following shows two ways of specifying the
same address (where dates is an array of type int)?
- *dates + 2 == dates[2]
- dates + 2 == *dates[2]
- *(dates + 2) == dates[2]
- dates + 2 == &dates[2]
- Which one of the following shows two ways to specify the
same value (where dates is an array of type int)?
- *dates + 2 == dates[2]
- dates + 2 == *dates[2]
- *(dates + 2) == dates[2]
- dates + 2 == &dates[2]
- Which one of the following adds 2 to the first
element of dates (where dates is an array of type int)?
- *dates + 2
- dates + 2
- *(dates + 2)
- dates + 2
- When an array name is used in a function call, you actually
pass the ___ of the ___ element(s) to the called function.
- value, first
- value, all
- address, first
- address, last
- Which one of the following will add 1 to an array
element (where ptr is a pointer to int)?
- *ptr++
- *++ptr
- (*ptr)++
- *(ptr++)
- Which of the following statements is valid, given the code
int urn[3];
int * ptr1;
- urn++;
- ptr = urn++;
- ptr++;
- Both b and c are valid.
- How many elements does the following array contain?
rain[3][10][3]
- 36
- 40
- 60
- 90
- Two-dimensional arrays are also called _____ of arrays.
- many-to-many
- multiple-element
- an array
- functional
- The declaration format for a one-dimensional array is?
- type name {size};
- type name [size];
- type &name[size];
- type *name[size];
|