# Write a c program to generate fibonacci series without recursion

• Fibonacci series starts from 0 ,1 and the next number should be sum of previous two numbers.
• 0+1=1, so the next number in Fibonacci series in c program is 1. 0 1 1
• 0 1 1 2 3 5 8.. and so on.
• Now let us see and c language example program on fibonacci series.

Fibonacci series in C language:

• First print 0, 1 by default.
• and start from 2 and iterate upto n-1 using for loop.
• inside loop assign n3=n1+n2;
• and ptint sum. printf(" %d",n3);
• Assign n2 value to n1. n1=n2
• Assign sum to n2:  variable n2=n3;

Program #1 : write a C program to print / generate fibonacci series up to n numbers.  Take input from user without recursion

1. #include <stdio.h>
2. #include <stdlib.h>
3.
4. int main()
5. {
6. int n1=0,n2=1,n3,i,number;
7. printf("Enter the number of elements to be printed in Fibonacci series:");
8. scanf("%d",&number);
9. printf("\n%d %d",n1,n2);//printing 0 and 1
10.
11. for(i=2;i<number;++i)//Starts from 2 to given number-1
12. {
13.   n3=n1+n2;
14.   printf(" %d",n3);
15.   n1=n2;
16.   n2=n3;
17. }
18. getch();

Output:

#### Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.