Skip to content

CPRO-Session1/Assignment5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

Assignment5

Objectives

To gain experience writing functions and using recursion.

Part 1

  1. Write a program, recurseFibonacci.c, that uses a recursive function to print the first K Fibonacci numbers in sequence. In the Fibonacci sequence, each number is the sum of the 2 before it. The first 2 numbers in the sequence are 1.

  2. In a separate program, loopFibonacci.c, write the same Fibonacci sequence as a loop.

Part 2

In a text file assignment5.txt, answer the following questions:

  1. How would you call the following function? Give an example of what it would look like written inside of the main() function and explain your code in detail.
	int fxn(int a, float b, int c)
  1. Explain the difference between recursion and iteration. When/why is one preferable over the other? Why is recursion worse in other cases?

  2. How does a compiler work? Explain step by step.

Submission Guidelines

Please include your name and a description in a comment at the top of your code files. Please also include your name at the top of your assignment5.txt file.

All files must be submitted via GitHub by 10:00am 7/6.

Releases

No releases published

Packages

No packages published