The quizzes give you a good idea of the style of questions. But unlike the quizzes, the exam is closed book.
Following are questions to stimulate the preparation of the exam. The questions below are not meant to be typical for the exam, but to test you current knowledge of the materials.
int hash ( char c );
/* returns 0 for c equal to a,b,c,..,or g,
1 h,i,j,..,or n,
2 o,p,q,..,or t,
3 u,v,w,..,or z */
void graceful_print ( int c );
/* prints c if it is not a control character,
otherwise nothing happens */
int bitcnt ( int n );
/* returns the number of ones in the binary representation
of the integer number n */
{ walking, slow, normal, fast, racing }
float distance ( speed s, float t ); /* returns miles traveled when driven at the given speed s for t hours */
#include<stdio.h>
int main(void)
{
float e = 2.718;
float *p = &e;
printf("%f", *p);
*p = 2.718281;
printf("%f", *p);
return 0;
}
Draw a diagram to illustrate the relations between p and e.
Indicate the values of those variables before and after executing
the last assignment.
What does the program print?
int OddAdd ( int *s, int n );
int main(void)
{
int sum = 0;
OddAdd(&sum,3);
return 0;
}
int OddAdd ( int *s, int n )
{
int a = (n % 2 == 1)? n : 0;
*s += a;
}
Make a diagram representing all variables in main and OddAdd.
Illustrate with the diagram what happens before, during, and after the
call of OddAdd(&sum).
Please note the policy on skipping exams:
What this means is that if you decide not to take one midterm exam, your final exam will be weighted for one hundred points more.
What it does NOT mean is that you can drop the score of a midterm exam. If you take the midterm, then your score counts. So, please be prepared when you show up for the exam.