Skip to content

Commit 7831fa3

Browse files
committed
chapter 14 exercises
1 parent 2f6aa31 commit 7831fa3

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

ex.14.1.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdio.h>
2+
3+
int howMany (void)
4+
{
5+
return 2;
6+
}
7+
8+
typedef int (* FunctionPtr) (void);
9+
10+
int main (void)
11+
{
12+
FunctionPtr func;
13+
14+
func = howMany;
15+
16+
printf ("this many: %i\n", func ());
17+
18+
return 0;
19+
}

ex.14.2.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <stdio.h>
2+
3+
enum month {
4+
january, february, march, april, may, june,
5+
july, august, september, october, november, december
6+
};
7+
8+
char *monthName (enum month aMonth)
9+
{
10+
char *monthNames[12] = {
11+
"January", "February", "March", "April", "May", "June",
12+
"July", "August", "September", "October", "November", "December"
13+
};
14+
15+
return monthNames[aMonth];
16+
}
17+
18+
int main (void)
19+
{
20+
enum month aMonth = october;
21+
printf ("%s\n", monthName (aMonth));
22+
23+
return 0;
24+
}

ex.14.3.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <stdio.h>
2+
3+
int main (void)
4+
{
5+
float f = 1.00;
6+
short int i = 100;
7+
long int l = 500L;
8+
double d = 15.00;
9+
10+
printf ("%p\n", l + i / (i * 2.0));
11+
12+
return 0;
13+
}

0 commit comments

Comments
 (0)