Some sample exam 1 questions (note that homework questions are in many
cases also good samples of exam 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

2. Prepare a structure chart/outline for how you would purchase a bottle
   of Coke in the cafeteria (be specific on the actions you to take).

3. Given the structure chart/outline you produced in the previous
   question, produce the corresponding outline/structure chart.

4. In the following program circle five syntax errors and indicate what is
   wrong for each of the things you circle:

   include 
 
   const PI = 3.14159;
 
   int main () {
 
     int x; y1;
 
     character c1;
 
     printf("Enter a value for three times X);
 
     scanf("%i",x);
 
     printf("x times three is %f\n",x,PI * x);
 
   }

5. 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

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

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

8. Rich needs help, he needs to produce a piece of code showing a table
   similar to the one below.  He has written part of the code but needs you
   to complete it.
   
   The table would be the following if the number of Hammers,
   Nails, and Screws purchased are 2, 150, and 20 respectively:

   Item     #    Cost
   -------------------
   Hammer   2  $ 35.00
   Nail   150  $  7.50
   Screw   20  $  5.00

   Here is the code so far:

   #include 
   
   #define HAMMER_COST 17.50
   #define NAIL_COST    0.05
   #define SCREW_COST   0.25
   
   int main () {
     int num_hammers;
     int num_nails;
     int num_screws;
   
     /* YOU MAY WANT TO ADD EXTRA VARIABLES */
   
     printf("Please enter the number of hammers, nails and screws purchased: ");
     scanf("%d%d%d",&num_hammers,&num_nails,&num_screws);
   
     /* YOUR CODE GOES HERE */
   
   }

9. 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.

10. 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.

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

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