Function Project
COP-3223H
Table of Contents
1. Overview
In this project, you will implement a function that computes Fibonacci sequences.
2. Repository setup
Log into eustis:
ssh NID@eustis.eecs.ucf.edu
Go to your local repository: Be sure you have already completed the git exercise before attempting this project.
cd ~/cop3223spring26/assignments
Create and enter a directory for the function project:
mkdir function cd function
You only need to mkdir once to create the directory.
Make sure you are in the right directory
pwd
You should see
/home/net/NID/cop3223spring26/assignments/function
3. Create the function
Make sure you are in the right directory
pwd
You should see
/home/net/NID/cop3223spring26/assignments/function
3.1. Function implementation
Create a function called fib that takes an integer and returns an integer. The function will take integers greater than or equal to 0. Test cases will not test values less than 0 or that result in values greater than the maximum integer size.
The function should produce the following outputs given these inputs:
fib(0)should output 0fib(1)should output 1fib(N)should outputfib(N - 1) + fib(N - 2), where N is any integer greater than 1.
3.2. main method
Use the following main method that calls fib:
int main(int argc, char **argv) {
int n;
scanf("%d", &n);
printf("%d\n", fib(n));
}
3.3. Example inputs and outputs:
fib(7) should return 13
fib(19) should return 4181
3.4. Program name
The program must be called function.c and must be in the function directory, i.e., the full path should be
~/cop3223spring26/assignments/function/function.c
Compile and run the program whenever you make changes using
cd ~/cop3223spring26/assignments/function/ gcc -o function function.c ./function
Be sure there is no other output besides the required output as the grading will be automatic. If you would like to have debugging output, use fprintf(stderr, "...", ...); instead of printf.
4. Submitting your program via git
This assumes you have already setup your repository and that you are still in your hello directory in your repository.
4.1. Add and commit the file
Enter
git add function.c git commit function.c
Write an appropriate commit message. Remember that you will need to save (Ctrl-x Ctrl-s) then quit (Ctrl-x Ctrl-c) the emacs editor that pops up. If you are having trouble, be sure that you have completed the git project first.
Do not commit the backup file function.c~ nor the function program. Use a .gitignore file to exclude those from the repository, so they won't show up when you type git status.
Then to synchronize the changes to the remote git repository on the grading server:
git push
5. Self-check
5.1. Remove the previous self-check
If you have already run the self-check, you can remove it like this
rm -rf ~/tmp/assignments_selfcheck
Double-check the path carefully to avoid deleting the wrong directory.
5.2. Make a fresh clone of your project
git clone gitolite3@eustis3.eecs.ucf.edu:cop3223/$USER/assignments ~/tmp/assignments_selfcheck
You should see something like
Cloning into '/home/net/NID/tmp/assignments_selfcheck'... Welcome to eustis.eecs.ucf.edu. Please use your NID and NID password to log in. See http://t.cs.ucf.edu/help/eustis for additional instructions. remote: Enumerating objects: 16, done. remote: Counting objects: 100% (16/16), done. remote: Compressing objects: 100% (12/12), done. remote: Total 16 (delta 1), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (16/16), done. Resolving deltas: 100% (1/1), done.
If you see
fatal: destination path '/home/net/NID/tmp/assignments_selfcheck already exists and is not an empty directory.
5.3. Enter the fresh clone's directory
cd ~/tmp/assignments_selfcheck/function
5.4. Make sure function runs correctly
cd function gcc -o function function.c ./function
6. Grading schema
| Criterion | Points |
|---|---|
| function.c exists and compiles | 1 |
| The program runs correctly, prorated by successful test cases | 3 |
| TOTAL | 4 |