ECE-1011 (SPRING 2003)

QUIZ #4 PREP SHEET

NOTE: Some of these questions ask you to think beyond the strict information given in the text.

(p128) In order to interact with a file, what must be associated with it?

  1. file handle
  2. file pointer
  3. data buffer
  4. I/O stream

(p128) When opening a file, what two arguments must be supplied to fopen()?

  1. file name, access mode
  2. file name, file location
  3. access mode, file size
  4. file name, file size

(p129) What is the only significant difference between printf() and fprintf()?

(p129) What is the only significant difference between scanf() and fscanf()?

(p130) What are the three common file structures as far as controlling how the program determines how much data to read from a file?

(p130) How can the fscanf() statement be used to detect when the end of a file has been reached?

(p137) What is one concern that must be considered when selecting a sentinel value?

(n/a) While covered in the book, it is very important (some would argue critical) that the success of every fopen() call be verified before any attempt to access the file, for reading or writing, is made. How can this be done?

(p140) Of the following, which is the best description of linear regression?

  1. A means of finding the straight line that exactly matches all of the data in a data set.
  2. A means of determining which y-value corresponds to an x-value that lies between two known data points.
  3. A means of finding the straight line that, overall, provides the best fit to all of the data in a data set.
  4. A means of generating a data file having a large number of linearly related data points.

(p162) Which of the following is not an advantage and/or goal of using the principle of modularity in your programs?

  1. Execution speed can be greatly enhanced because any one module is only performing a fraction of the entire program.
  2. Code can be developed, tested, and debugged in small, easier to manage pieces.
  3. Code that performs common tasks can be reused easily either within a single program or across multiple programs.
  4. The "divide-and-conquer" approach to problem solving can be facilitated because various parts of a problem can be assigned to different people and developed in parallel.

(p165) Given the following function definition:

double sinc(double x)

{

   if (fabs(x) < 0.01)

        return( 1.0 - ( (x*x)/6.0) );

   else

        return( sin(x) / x );

}

Draw a flowchart for the this function.

(p165) Write a complete function called log_b() that takes two arguments, both of type double, and returns a value of type double. The return value should be the logarithm of the first argument taken to the base of the second argument. Be sure to indicate any standard library files that must be included in order for this function to run.