EEGR-409-001, C Language Programming, Due Feb 18, '08
1. Develop functions and test them using a main().
int max_3(int a, int b, int c);
int min_3(int a, int b, int c);
int middle_3(int a, int b, int c);
2. Develop and test a function which calculates the length of a line between x1, y1 and x2, y2
float line_length(float x1, float y1, float x2, float x2)
3. Develop and test a function which fills the upper left of the terminal with a square block of characters.
void fill(char ch, int num);
For example;
fill(#, 5);
should result in;
#####
#####
#####
#####
#####
4. Develop and test a function which returns the sum of all factors of a number;
int sum_factors(int num);
For example, if num is 6, the factors are 1, 2, and 3. The sum is 6.
(Coincidentally, in this case, the sum of the factors is the same as the number. This is often termed a "perfect number").
5. Develop and test a function to calculate the nth Fibonacci number.
int fib(int num);
The following are the first few Fibonacci numbers.
n 0 1 2 3 4 5 6 7
fib 0 1 1 2 3 4 5 13
6. Develop and test a function taht calculates the number of seconds since midnight.
int calc_secs(int hr, int mi, int se);
7. Develop a game "Guess the number". The computer randomly selects a number in the range of 1 - 1000 and prompts the user to guess the number. For each guess, the computer responds, "Too large", "Too small" or "Correctomongo". The game continues until the user selects the correct number.