print Fibonacci series using array in c language
kya hoti hai fibonacii series-
aise series jisme agla term pichle do term k sum se bna hota hai jaise 0,1,1,2,3,5............
is series mai phla term 0 hai aur dusra 1 to 3rd term 0+1=1,4th term=third+second term=1+1=2
aise hi ye series aage badte rhaegi.
#include<stdio.h>
int main()
{
int k=2,a[k],n;
scanf("%d%d%d",&n,&a[0],&a[1]); /*yaha n number of term hai jaha tk aap series print krwanna chahte ha a0 and a1 series k phle aur dusre term i*/
printf("first %d term of fibonacii series is ",n);
printf("%d %d",a[0],a[1]);
for(k=2;k<n;k++)
{
a[k]=a[k-1]+a[k-2];
printf(" %d",a[k]);
}
return 0;
}
Comments
Post a Comment