NAME (1pt): _________________________    SEC (1pt):    1    2    3    4    

 1) (1point) Which header file must be included in your program in order to use printf() or scanf()?

 #include <stdio.h>  NOTE: While we will accept simply stdio.h as a correct answer, giving the entire statement is to your benefit.

 2) (2points) Write the conversion specifier that would be used to print out a variable of type double such that it had at least two blank spaces before the number, the number always took an additional four spaces for the digits left of the decimal point and printed out three digits to the right of the decimal point?

 %10.3f      (to yield: bbnnnn.nnn)

 3) (1point) What does the ampersand, '&', prefix do to a variable identifier and why is that (frequently) needed with scanf()?

It is the address operator. It supplies the address of the variable instead of the value stored in that variable. The scanf() function  needs to know the address (i.e., the memory location) where it is going to store the value that is input. Note that no where in this process is any memory being allocated. The memory for the variable was allocated when the variable was originally declared.

 4) (1point) Which header file must be included in your program in order to access most of the mathematical functions?

 #include <math.h>

5) (1point) Why does the Standard C Library include the function atan2() in addition to atan()?

The atan() function uses a single argument - the ratio of y to x is the usual interpretation - and it has no way of knowing the signs of the individual components. Hence it returns an angle, in radians, that is restricted to the first and fourth quadrant (-pi/2 to +pi/2). The atan2() function takes two arguments specifically so that the sign information for both sides is available to it and therefore it can return the angle, again in radians, in all four quadrants (-pi to +pi).

NOTE: Just indicating that one takes one argument and the other takes two arguments is not a sufficient explanation of WHY a version that takes two arguments is provided in addition to the one that takes just a single argument.

6) (1point) Which of the following statements is incorrect regarding the character comparison functions found in the Standard C Library?

  1. If the result of the comparison is false, a zero (0) is returned.
  2. If the result of the comparison is true, a one (1) is returned.  <== Correct Response
  3. No change is made to the value stored in the variable used in the comparison.
  4. Each function requires an integer argument and each function returns an integer argument.

 7) (1point) The function printf() returns a value. What does that value represent?

The number of characters printed.