Headlines
Loading...
C Program to Print Fibonacci series using arrays.

C Program to Print Fibonacci series using arrays.

Print Fibonacci series using arrays.*/

#include<stdio.h>

#include<stdlib.h>

void main()

{

 int arr[100],n,i,a,b;

 clrscr();

 printf("Enter the number of values :");

 scanf("%d",&n);

 a=0;

 b=1;

arr[0]=a;

arr[1]=b;

 for(i=2;i<n;i++)

 {

  arr[i]=a+b;

  a=b;

  b=arr[i];

 }

  for(i=0;i<n;i++)

 {

 printf("\n%d",arr[i]);

 }

 getch();

}

 

/*Output

Fibonacci Series

 

 

Enter no of elements of Fibonacci Numbers :4

1

1

2

3

*/
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***