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 by typical for the exam, but to test you current knowledge of the materials.
int n = 13;
printf("%x", n);
#include <stdio.h>
int main(void)
{
int i = 4;
int j = 5;
while (i--) if (i % 2)
while (j--) printf("%d\n",j);
else j = i; return 0;
}
Make a table with three columns: step number in while loop,
value for i and value for j.
f(x) = 0 if x < 0,
= 1 if x >= 0 and x < 1,
= 2 if x >= 1 and x < 2,
= 3 otherwise
where x and f(x) are of type float.
Can you use a switch? Explain why you can or cannot.
[jan@galois]% calc
8.2
3
*
24.6
[jan@galois]%
Give first a basic version without any control on input
or printing of error messages.
Then identify what can go wrong and make the program more
robust adding extra checks and more user friendly by printing
error messages.
int reward ( int outcome, int bet )
/* returns the tokens gained depending on the values of bet
and the outcome; returns 0 if the token used to place the
bet can be kept, and -1 in all other cases */
Give the main program to implement the project.
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.