The questions below are meant to stimulate the preparation of the final exam. They cover some of the most important but not all topics in the course. You must review all course materials: textbook, exercises, lecture notes, quizzes, and exams.
char random_letter ( void );
/* returns a randomly generated lower case letter */
Give a definition of random_letter.
Describe the design of a program that would simulate this ATM machine. Sketch the organization of the flow of the program and give prototypes of the most important functions in the program. Do NOT write definitions of functions, just use comments to specify their input and output.
void replace ( char c1, char c2 );
/* reads characters from input until EOF is reached,
copies the symbols to the output, except that every
occurrence of character c1 is replaced by c2 */
Give two definitions: once using only getchar and putchar
and once using only scanf and printf.
double weighted_sum ( int n, int a[] );
/* returns the sum of a[i]/(i+1) */
char grade ( curve s ); /* returns the representation of s as a character */
curve assign_grade ( float p );
/* returns the corresponding grade with the percentage p,
as follows : p >= A : A; A > p >= B : B; B > p >= C : C;
C > p >= D : D; and p < D : E */
The function assign_grade must adapt itself to the changing
values of A, B, C, D, and E, without changing its definition.
void f ( float *p );
#include<stdio.h>
int main(void) void f ( float *p )
{ {
float x = 3.0; static int i = 0;
f(&x); static float x = 1.0;
f(&x); float y = (i==0)? 0 : x * *p;
printf("%f", x); i++; x = *p;
return 0; *p = y + 1.0;
} }
Make a diagram representing all variables in main and f.
Illustrate with the diagram what happens before, during, and after each
call of f(&x). What is printed?
FINAL EXAM is in Lecture Center C6 on Monday 3 December 2001 from 1:00 till 3:00PM.
Please let me know as soon as possible if you cannot attend the exam and need to schedule a makeup.
Incomplete grades are only given in exceptional cases. At least the two following conditions must be satisfied: the student is in good standing (has decent scores on midterm exams, projects, and quizzes) and the student is unable to take an exam during the finals week.