CPPForSchool.com: Flow of Control Set 2: Assignment 12
12.
Write a program to print Fibonacci series of n terms where n is input by user :
0 1 1 2 3 5 8 13 24 .....
It never ceases to amaze me on how much math I missed out. That is correct! Once again, I have to tackle an assignment task with a new concept, this time Fibonacci series. According to MathsIsFun, the Fibonacci Sequence the following:
The Fibonacci Sequence is the series of numbers:
It never ceases to amaze me on how much math I missed out. That is correct! Once again, I have to tackle an assignment task with a new concept, this time Fibonacci series. According to MathsIsFun, the Fibonacci Sequence the following:
The Fibonacci Sequence is the series of numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
The next number is found by adding up the two numbers before it.- The 2 is found by adding the two numbers before it (1+1)
- The 3 is found by adding the two numbers before it (1+2),
- And the 5 is (2+3),
- and so on!
Also, for this assignment, I decided to utilize the continue statement. This allows for the next conditional statement to be utilized instead of exiting the loop. According to GeeksforGeeks, continue statements are defined as:
"Continue is also a loop control statement just like the break statement. continue statement is opposite to that of break statement, instead of terminating the loop, it forces to execute the next iteration of the loop."
With that said, here is my source code and output. The sample source code and output is at the bottom for comparison.
Comments
Post a Comment