CEG220: Introduction to C
Programming for Engineers – I
Section 2
Homework for Week 5
- Writing
functions
- that
compute the nth Fibonacci number, where fibonacci (0) = 0, fibonacci(1) =
1. Recall that
fibonacci(n) =
fibonacci(n-1) + fibonacci(n-2).
- write
a function that computes the nth row of Pascal’s triangle.
- Enumerated
types are integer values that have a user-defined significance. For
example, I can define an enumerated type called ClassificationType that
can have values Kingdom, Phylum, Class, Order, Family, Genus, Species. We
define it this way: enum ClassificationType = { Kingdom, Phylum, Class,
Order, Family, Genus, Species }; By default, Kingdom = 0, Phylum = 1, etc.
You can also specify its values, but each value and name must be unique.
We can define ClassificationType as: enum ClassificationType = {Kingdom =
1, Phylum = 10, Class = 3, Order = 12, Family = 4, Genus = 5, Species =
7};
- Define
an enumerated type that expresses time zones
- Write
a function that, given a raw time in GMT and a TimeZoneType, computes the
time for that time zone
- Define
an enumerated type that expresses computer platforms: UNIX, Windows,
Macintosh, and Linux
- Write
a function that performs byte-swapping on a short, integer, and long if
the PlatformType variable == Windows.