Some sample final questions:

1. Define the following terms:

   Computer Hardware

   Computer Software

   Top-Down Programming

   Structure Chart

   Global Declaration

   Reserved Word

   Comment

   Literal Constant

   Memory Constant

   Associativity

   Precedence

   Side Effect

   Implicit Casting

   Infinite Loop

2. Assume:
   X = 2;
   Y = 7;
   Z = 9;
   A = 0;
   B = 1;

   What are the values of:

   X + Y * Z
   X * Y + Z
   X - Y - Z
   X / Y * Z
   Y % X
   sqrt(Z)
   pow(X,Y)
   rint(7.6)
   floor(7.6)
   ceil(7.6)
   X + Y - Z * X + Z - X % Y
   X && Y
   A || B
   !A
   !A && B
   !B || A
   (X < Y) && Z > X

3. A field specification may have width and precision values, how
   are these used?

4. What is meant by the term prompting for input?  What are
   characteristics of a good prompt.  Show an example.

5. The logical AND (&&) and logical OR (||) operators are "short
   circuit" operators.  What does this mean?

6. Write a function Factorial that takes an argument N and calculates
   (returns) 1 * 2 * 3 * 4 * ... * N.  For example, Factorial(4) should
   calculate 24 (1 * 2 * 3 * 4).

7. Rich wants to write a function that prompts a user for three pieces
   of information: an id number (integer), a salary (floating-point) and
   a favorite letter (character).  Help Rich out and write this function.
   Your function should prompt the user for each value and the function
   should produce the three values.

8. Give an example of a switch statement with at least three cases
   and a default case.  Now, rewrite your switch statement as a set of
   if-else statements.

9. Give an example of a multiway selection problem that would be
   difficult to do with a switch.

10. Translate the following for loop into a do-while loop:

    for (I = 0, tot = 0, cnt = 0; I < N; I += 2) {
      tot += I;
      cnt++;
      printf("%.2f\n",(float) tot / cnt);
    }

11. Write a piece of code to produce the following output using at most
    one newline character in your print statements:

    *
     **
      ***
       ****
      ***
     **
    *

12. What is the output of the following piece of code:

    for (I = 0; I < 12; I++) {
      for (J = 4 - (I % 4); J > 0; J--)
	printf(" ");
      for (J = 0; J < (I % 4) + 1; J++)
	printf("X");
      printf("\n");
    }

13. Give a piece of code that will copy the characters from a text
    file file1.txt to a new file file2.txt.  Furthermore, when copying
    the characters, any lower case characters in file1.txt should be
    written as a corresponding upper case character in file2.txt (if
    the character 'a' is read from file1.txt, the character 'A' should
    be written to file2.txt).

14. How do the fgetc and ungetc functions work?  Indicate the arguments
    each takes and what values they return.  Also, give an example of
    how each function is used.

15. Also, you may want to see if you can produce the right output for the program at this link .