- Write a C program that prints the Fibonacci sequence from 0 to 144. (Hint: Use three variables,
printf
, and awhile
loop.) - For extra credit, write another program that prints the ratios of consecutive Fibonacci numbers to four decimal places, from 1/1 to 144/89. What number do these ratios approximate?
Paste your code (a single C file) into a GitHub Gist and post the link to our Slack channel by Friday at 5pm. I'll post a solution to both the homework and the extra credit here between then and our next meeting.
GitHub Gists are like Pastebin in that they're used to share code snippets and can be embedded in Web pages. However, as this post explains, Gists are full GitHub repositories, so they can be cloned, forked, and pushed like regular repos. In addition, Gists can contain multiple files, which is what I'll do here to post lesson plans and homework assignments over the next couple of months.
If you do the extra credit, put the code in a second file in the same Gist and clearly label which file is the homework and which file is the extra credit using a comment near the top of one or both files.
We're not at school so these homeworks won't be for a grade. They're just so that I can assess how well I'm teaching you guys. Of course you don't have to do them, but I'll make these homeworks fun so you'll want to do them.
Mentors, do them too!
On Saturday, we'll look at pointers, arrays, strings, and memory allocation. We might also talk about header files, the C compiler, and makefiles, and if we're lucky we'll get a head start on file I/O. See ya then!!
-- Aidan