c program to generate fibonacci series using Function
In our previous post, we discussed about what is Fibonacci Series and C program to Generate Fibonacci Series. Now in this post we are going to write C program to calculate first n Fibonacci numbers of Fibonacci Series but this using function.
This Program Accept one Input from user ( let’s say it as n ) and prints first n Fibonacci numbers of Fibonacci Series.
|C Program to Calculate Fibonacci Number using Function|
Note : This program accepts only Numbers above 2 (because Fibonacci Series starts with 0 and 1). If you enter 0 or 1 it will simply display one Error message and asks for one more value.
In above program print_fibonacci is function. returns nothing and Accepts one Integer.
here is the prototype of print_fibonacci.
void print_fibonacci( int );
More programs on Fibonacci Series :
- Calculate nth Fibonacci Number.
- C Program to Generate Fibonacci Numbers upto given Number.
- C program to Generate First n Fibonacci Numbers (same as above program but without using Function)