DAY18
Thursday, 21 June 2012


Today is an EXAM day.

Exam #1 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.

The exam has 8 questions. Each 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, 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.

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.

The exam covers chapters 3, 4, 5, and 6; labs 1 through 5; homeworks 1 through 5. However, you should concentrate on the basic programming skills that were covered.

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


Last revised on 17 June 2012.