Fibonacci series up to n using C
Write a C program to find Fibonacci series up to n
C program for Fibonacci series using a for loop statement. Numbers of these(0,1,1,2,3,5,8,…) sequence are known as Fibonacci numbers.
The sequence is a Fibonacci series where the next number is the sum of the previous two numbers. The first two terms of the Fibonacci sequence is start on 0,1,…
Ex. limit is Fibonacci series 8
Sequence is 0,1,1,2,3,5,8,13
Its followed on addition operation. Next number is addition of before first two numbers .
Step 1.Initialize variables limit, N1=0, N2=1, N3, i.
Step 2.To take user input for limit of serious.
Step 3.Display N1, N2 value .
Step 4.We use for loop with the condition(i=0;i<limit).
Step 5.Compute N3 = N1 + N2 and n1=n2. && n2=n3.
Step 6.Than display N3 as output and close the loop
//To initialize variables
//To take user input
printf("enter a limit of series \n");
printf("Fibonacci series %d %d ",n1,n2);
//To use this loop for given length
//n1 and n2 sum store in new variable n3
enter a limit of series
Fibonacci series 0 1 1 2 3 5 8 13 21 34