int value ( char c );
/* returns 26, 25, .. , 1 if c equals respectively A, B, .. , Z;
returns 0 for any character that is not a capital letter */
Give the definition of the function value :
int value ( char c )
+--------+
| /10 |
+--------+
+--------+
| /15 |
+--------+
double value ( int q, int d, int n, int p );
/* returns the value of the given number of coins, where
q = number of quarters (value is $0.25 apiece),
d = number of dimes (value is $0.10 apiece),
n = number of nickels (value is $0.05 apiece), and
p = number of pennies (value is $0.01 apiece). */
Give the definition of the function value :
double value ( int q, int d, int n, int p )
+--------+
| /10 |
+--------+
void write_octal ( int n );
/* writes the integer n in the octal number system,
starting with the least significant digit (thus backwards) */
+--------+
| /15 |
+--------+
{ morning, noon, afternoon, evening, night }.
In a 24 hour day, the morning starts at 6 (= 6AM),
noon at 11 (= 11AM), the afternoon at 13 (= 1PM), the evening
at 19 (= 7PM), and the night at 21 (= 9PM).
void read ( day24 *dt );
/* scans a floating point number t, using the convention that
for 6 <= t < 11, we call this time of the day morning;
for 11 <= t < 13, noon; for 13 <= t < 19, afternoon;
for 19 <= t < 21, evening, and otherwise we call it night. */
Give the definition of read below :
void read ( day24 *dt )
+--------+
| /25 |
+--------+
void R ( int *p );
#include<stdio.h>
int main(void) void R ( int *p )
{ {
int a = 3; static int cnt = 0;
R(&a); int i = *p * ++cnt;
R(&a); *p += i;
printf("%d", a); }
return 0;
}
Make a diagram representing all variables in main and R.
Illustrate with the diagram what happens before, during, and after each
call of R(&a). What is printed?
+--------+
| /25 |
+--------+
FINAL EXAM is in Lecture Center C6
on Monday 3 December 2001 from 1:00 till 3:00PM.