DAY39
Thursday, 09 August 2012


Today is an EXAM day.

In order to give everyone extra time on the exam, I will make the exam available starting at 10:45 on Thursday morning, although you may come to class at the usual time and start then. Since one person must go to another class at 12:30, each person will be allowed 1 hour and 45 minutes total. This means that I would like you to write on your test the time you started the exam and the time you turned it in.

Exam #2 will be handed out and completed during class time, in the lab DSL152.

The exam is printed on paper, and you will do your work on paper. I will bring paper to class for you.

Each exam question asks you to write the C code that carries out a specific task. There will be no TRUE/FALSE questions. There will be no questions about definitions or language rules. All you will be asked to do is write C code.

When answering the question, in general, you do not need to write an entire program. You do not need to declare any variables. Concentrate on showing how to carry out the desired task.

However, there may be one question, which will be clearly marked, which requires you to write a complete C function. In that case, you need to write down all the information, including the function "header" or "prototype", the variable declarations, the code, the return statement, and all the curly brackets.

Sample question 1: Let x be a number greater than 1. Consider the sequence x, x*x, x*x*x, ... The numbers in this sequence grow larger and larger. Write a loop that prints out the first value in this sequence that is greater than 50.

Possible answer 1:

        number = x;
        while ( number <= 50 )
        {
          number = number * x;
        }
        printf ( "The number is %g\n", number );
      

Sample question 2: Write C code which prints the even numbers from n down to 1. If n is 73, the first number to be printed is 72, and the last will be 2.

Sample question 3: The meal plan at Marianna High School requires a student to pay $50 to participate, and there is no further charge for the first 5 meals. Meals 6 through 20 are $7 each. Meals after that will cost $5 each. Write code that reports the total amount spent if a student eats m meals.

This exam is cumulative: you are responsible for all material covered in the course lectures, labs, and homeworks. As I stated earlier, however, you are NOT responsible for the material on pointers that was covered in the last week.

During the exam, you may refer to notes you have made on one sheet of paper. No other references are allowed.


Last revised on 03 August 2012.