Here we written code for print Fibonacci series with output.
For improvement of your coding skills we give some tasks along this. If you solve this tasks and send to our email (firstname.lastname@example.org) with your details. we will display your details(like Name, City, college, photo) in our site.
Task: Write a C program to generate the given range of terms of Fibonacci series.
For example user entered 7 & 10 then output will be : 8 13 21 34
Write a C program to generate the first n terms of Fibonacci series.
int f,s,t,n,i; //’f’ is 1st num,’s’ is 2nd num,’t’ for 3rd new generated num, ‘n’ is no.of terms, ‘i’ is for iteratons.
printf(“Enter a value : “);
scanf(“%d”,&n); // Read the number terms to print from the series.
printf(“Please enter a valid number\n”);
printf(“The FIBONACCI Series is :\n%d”,f);
t=f+s;//By adding of preceding numbers next numbers will generate in Fibonacci series.
s=t;//Shifting the last two terms of series to ‘f’ & ‘s’ for generating next number in the series.
i) Enter a value : 16
The FIBONACCI Series is :
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610
ii) Enter a value : 0
Please enter a valid number